Safe HTML
Overview
Several places in a form take HTML: help texts, the Rich Text and HTML elements, confirmation messages. WebForms cleans some of them before a visitor sees them and shows others exactly as written. This page lists which is which. There's no setting for it. The rules are the same on Luma, Hyvä and Breeze.
What admins write
| Place | What reaches the visitor | What's removed | Notes |
|---|---|---|---|
| Field help text and tooltips | Bold, italic, underline, strikethrough, small text, links, lists, paragraphs, line breaks, images. | Every class, style and id; scripts, iframe, style blocks and SVG with their content; links that start with javascript:. Headings and tables lose their tags, and their text stays. | Links get a safe rel when they open in a new tab. Images must come from a web address. Every {{…}}, such as {{block}}, {{widget}} or {{config}}, is removed: help texts take no placeholders. |
| Rich Text element, Terms text | Bold, italic, underline, strikethrough, links and lists. | Everything else loses its tag: paragraphs, headings and tables become plain lines, and span keeps only its text. Images are removed. | The same link rules as help text. |
| Heading element | Plain text. | All HTML. | |
| Error messages when a submission is refused, such as Required Error Message | Bold, italic, links and lists in your own text. | Everything else. A value the visitor typed in the message is always shown as text. | |
| Field labels | Plain text. | All HTML. | |
| Option text of Checkbox, Radio and Swatches fields, the caption of a Toggle and of the Newsletter checkbox | Bold, italic and links. | Every other tag, every class and style. | An element can keep its id, so your developer's script can find it, for example a link that opens your terms. |
| Contact option names, Gallery picture labels | Plain text. | Nothing: any HTML shows as text. | Type plain text. |
| HTML element you add in the builder | Everything, as written, including scripts and the directives a CMS page accepts, such as {{block}} and {{widget}}. | Nothing. | Anything you paste here runs in your visitors' browsers, and in the admin when someone opens a submission. To show a store block or a widget on a form, put it here. |
| Callout text, Button text | Everything, as written, including scripts. | Nothing. | The builder shows the tags of a Button as text, but your store runs them. |
| Form description, text below the form, confirmation messages | Paragraphs, bold, italic, lists, links and images. Text and container elements keep their CSS classes and basic inline styles such as colors, sizes and spacing. Links keep basic inline styles but no classes. Images keep neither, only their width and height, within limits. | Headings, tables, frames, scripts, event attributes such as onclick, links that start with javascript:, styles that load anything from outside or move the element on the page, and every {{…}} except the form's own placeholders and the four address placeholders. | The form's own placeholders still work: {{var webform_name}}, {{var reference}}, {{var result.<code>.value}} and the like. Their values show as text, so a visitor's answer can't add markup. Four address placeholders work too: {{store url="…"}}, {{store direct_url="…"}}, {{view url="…"}} and {{media url="…"}}. Each prints an address on the current store view, so a link or an image works on every store view. Give it only its url or direct_url part. With anything more, such as _query, it's removed, and so is an address that leads off your store. A file name in the address may use Latin letters, digits, dashes, underscores, dots and slashes, and no spaces. A class or style changes how the text looks, but the text stays inside its own area of the form and can't cover the rest of the page. This holds for the confirmation message too, on the page, in a popup and after a redirect. A form from WebForms 3 keeps its description and the text below it as HTML elements that are cleaned the same way, address placeholders included. A confirmation message is part of the form page from the moment it loads, hidden until someone submits. Don't put anything in it that only people who sent the form should read. |
Who can write these: anyone whose role includes Edit Form changes help texts, elements and confirmations, and Add Form can import a whole form with its HTML. Give these permissions only to people you trust with your storefront's code, because the texts above can run scripts and show store blocks. See Permission reference.
An integration, such as an AI assistant, needs the extra permission Edit Form Scripts to put code into a form's texts. See API permissions.
What visitors type
| Place | What happens |
|---|---|
| Textarea and other text fields | Shown as plain text in the admin, in emails and in published results. Any HTML a visitor types shows as text. |
| Editor field | The visitor gets basic formatting: bold, italic, underline, lists, links, two heading levels and quotes. When the answer is shown, it keeps only basic formatting and links that start with http, https, mailto or tel: pictures, scripts, iframe and event attributes such as onclick are removed. The editor on the submission's edit page shows the answer as it was sent. |
| Messages in a conversation, from your team or from the customer | A message keeps the formatting the reply editor writes: bold, italic, colors, fonts, lists, links, images and tables. Other styles, classes and scripts are removed when the message is saved and each time it's shown, older messages included. Text pasted from Word or an email can lose part of its layout, but the words stay. A message stays inside its own box on the page. |
Emails and PDF documents
| Place | What's kept | What's removed |
|---|---|---|
| Email content | Text formatting, links, lists, headings, tables and inline styles from a fixed list. | Images, scripts, iframe, forms and SVG. Styles that load anything from outside. Advanced email content, which uses Magento template directives, isn't filtered this way. |
| PDF documents | The same as emails, plus images and classes. | A document with scripts, iframe, forms, SVG, video or audio can't be saved, whichever layout it uses. |
What's next
- Confirmation messages: write what visitors see after they submit.
- General field settings: where a field's help text and tooltip are.
- Permission reference: who can change form content.