What this is for
- Email snippets: check inline-styled HTML renders correctly before sending through your ESP.
- Component tests: a button, card or layout — tweak and re-render without a full dev server.
- Learning: write markup and see the result side by side; the
<script>tag runs in the preview iframe.
Sandbox notes
- The preview runs in a sandboxed iframe with scripts allowed but no parent access — your code can't touch this page or your data.
- External resources (fonts, CDN links) load normally; if the network blocks them, the preview still renders local markup.
- Forms inside the preview won't submit anywhere (sandbox blocks navigation) — that's a feature for testing.
For full-page previews with responsive widths, resize your browser window — the iframe scales with it. Pair with the Markdown Editor when you're drafting content rather than markup.
What happens in the page
render() takes the markup from the editor and writes it into an iframe through srcdoc, with a sandbox attribute attached. That combination is the whole design: the preview runs in its own document context, so scripts inside it cannot reach this page, cannot read its storage and cannot navigate the parent. Re-rendering only replaces the srcdoc, so nothing outside the frame is rebuilt.
Where it breaks down
Sandboxing cuts both ways: popups, top-level navigation, same-origin storage and some autoplay behaviour are blocked, which is why code that works locally can fail here. External images, fonts and stylesheets need a network connection. Invalid markup is not rejected — the browser repairs it and you see the repaired result. Nothing is saved, so a refresh loses the draft.
Privacy: no data leaves this tab
The preview runs in a sandboxed iframe with its own document context; your markup is never uploaded, and the frame cannot read this page’s data either.
Frequently asked questions
Can I run JavaScript in the preview?
Yes, but inside the sandbox: no popups, no top-level navigation, no access to the parent page or its storage.
Why are my images missing?
Either the URL is relative (the frame has its own document, so there is no matching file) or the host blocks hotlinking. Use absolute URLs.
Is my code saved?
No. There is no storage call; copy the markup out before closing the tab.