srcdoc
The srcdoc attribute holds the full HTML of the page to show in an iframe. The browser shows that HTML in place of a URL, and the frame document gets the URL about:srcdoc.
HTML attribute
Updated
On this page
Example
HTML
<iframe srcdoc="<p>Hello from the frame</p>" sandbox title="Preview" ></iframe>
When srcdoc and src are both set, srcdoc wins.
How to use it
Put the HTML in srcdoc. Add sandbox when the HTML comes from users or other sites.
<iframe srcdoc="<!doctype html><p>Preview</p>" sandbox="allow-scripts" title="Preview" ></iframe>
Wrap the value in double quotes. Escape each & as & first, then each " as ".
Learn more
Sources