Docs › Blocks
HTML block
Insert ready-made HTML (like a product page) with its classes and styles.
For HTML you already have: a product detail page, a banner, a hand-made layout. Unlike regular content, an HTML block keeps classes and nearly every CSS property.
Try it
Click the box below to get its bar, then try "Edit HTML".
Autumn sale
20% off everything
-20%
Code for this demo
createEditor('#editor', {
toolbar: 'heading | bold | htmlBlock | source | undo redo',
});How to use
- The
htmlBlockbutton opens a box to paste HTML into. "Insert" puts the block at the caret. - In the editor an HTML block is one piece: its text cannot be edited in place, and a click selects the whole block and shows its bar.
- The bar: Edit HTML (edit and apply in the same box, or remove), Move up, Move down, Remove.
What stays and what goes
| Inside an HTML block | Regular content | |
|---|---|---|
| class | kept (up to 12 per element) | dropped (only styles classes stay) |
| CSS properties | nearly all kept (grid, gradients …) | allow-listed ones only |
section article header footer aside main center | kept | tag removed, text kept |
script style form input button svg … | removed with content | removed with content |
Event attributes like onclick | removed | removed |
javascript: URLs, CSS url() and expression() | removed | removed |
| iframes | allowed sites only (allowedIframeHosts) | allowed sites only |
Saved HTML
<div data-html="">
<section class="promo" style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px; …">
…
</section>
</div>If your server sanitizes again, make sure its rules keep classes and styles inside div[data-html] (Security).
editor.exec('htmlBlock'); // open the HTML block dialogPresets
htmlBlock is only in the full preset, under ⋯. It suits admin screens better than boards open to visitors.
Options
| Name | Type | Default | Description |
|---|---|---|---|
htmlBlock | toolbar item | - | Insert or edit an HTML block |
allowedIframeHosts | string[] | - | Iframes inside the block also need a built-in video site, Google Maps, or a host from this list |