# trust(html) - [API](#api) - [How it works](#how-it-works) - [Security considerations](#security-considerations) - [Scripts that do not run](#scripts-that-do-not-run) - [Avoid trusting HTML](#avoid-trusting-html) --- ### API Generates a trusted HTML [vnode](vnodes.md) `vnode = m.trust(html)` Argument | Type | Required | Description ----------- | -------------------- | -------- | --- `html` | `String` | Yes | A string containing HTML text **returns** | `Vnode` | | A trusted HTML [vnode](vnodes.md) that represents the input string [How to read signatures](signatures.md) --- ### How it works By default, Mithril escapes all values in order to prevent a class of security problems called [XSS injections](https://en.wikipedia.org/wiki/Cross-site_scripting). However, sometimes it is desirable to render rich text and formatting markup. To fill that need, `m.trust` creates trusted HTML [vnodes](vnodes.md) which are rendered as HTML. ```javascript var view = m("div", [ m.trust("

Here's some HTML

") ]) m.render(document.body, view) // equivalent HTML //

Here's some HTML

``` Trusted HTML vnodes are objects, not strings; therefore they cannot be concatenated with regular strings. --- ### Security considerations You **must sanitize the input** of `m.trust` to ensure there's no user-generated Javascript in the HTML string. If you don't sanitize an HTML string and mark it as a trusted string, any asynchronous javascript call points within the HTML string will be triggered and run with the authorization level of the user viewing the page. There are many ways in which an HTML string may contain executable code. The most common ways to inject security attacks are to add an `onload` or `onerror` attributes in `` or `