iframe srcdoc works in Chrome 20+, Edge 79+, Firefox 25+, Safari 6+, Opera 15+, and Samsung Internet 4+. Learn iframe srcdoc browser support and limits.

Prince Dewani
May 6, 2026
The iframe srcdoc attribute is an HTML attribute that the WHATWG defines on the iframe element to embed inline HTML inside a frame instead of loading an external URL. Chrome 20+, Edge 79+, Firefox 25+, Safari 6+, Opera 15+, and Samsung Internet 4+ support it, while Internet Explorer never added support.
This guide covers what iframe srcdoc is, the browsers that support it, how it differs from the src attribute, how to use it with code, and the known limitations.
srcdoc is an HTML attribute on the iframe element. It holds an HTML document as a string, which the browser parses and renders inside the frame using about:srcdoc as the document URL. The WHATWG HTML Living Standard defines it, and srcdoc takes priority over the src attribute when both appear on the same iframe.
iframe srcdoc works in every modern desktop and mobile browser, with global support over 96 percent. Chrome shipped it first, Safari added it in version 6, Firefox in 25, and Internet Explorer is the only major browser that never supported it.
Chrome supports the iframe srcdoc attribute from Chrome 20 on Windows, macOS, Linux, and ChromeOS. Chrome for Android supports it from Chrome 25, the first stable Chrome for Android release that matched desktop parity. Chrome 1 to 19 ignored the attribute and fell back to the src URL or rendered an empty frame.
Microsoft Edge supports srcdoc from Edge 79, the first Chromium-based Edge build, on Windows, macOS, Linux, Android, and iOS. Legacy EdgeHTML Edge 12 to 18 did not support srcdoc at all and silently fell back to the src URL, which broke pages that relied on inline HTML embedding.
Firefox supports the iframe srcdoc attribute from Firefox 25 on Windows, macOS, Linux, and Android. Firefox for Android added support in the same release. Firefox 1 to 24 did not parse the attribute, so any iframe that depended on srcdoc rendered the src fallback or stayed empty.
Safari supports srcdoc from Safari 6 on macOS and from iOS Safari 6 on iPhone and iPad. Apple shipped both updates together in OS X Mountain Lion and iOS 6. Safari 3 to 5 on macOS and iOS Safari 3 to 5 did not support the attribute and rendered the src URL or an empty frame instead.
Opera supports srcdoc from Opera 15, the first Chromium-based desktop Opera. Opera 12 and earlier, which used the Presto engine, did not support srcdoc. Opera Mobile supports it from Opera Mobile 14 on Android, and the standalone Opera Mini proxy browser does not support srcdoc because it never executes attribute logic on the device.
Samsung Internet supports the iframe srcdoc attribute from Samsung Internet 4 on Galaxy phones and tablets. It is built on Chromium, so the parsing rules, sandbox behavior, and same-origin model match Chrome for Android. Earlier Samsung Internet builds shipped a Chromium core that did not surface srcdoc.
The legacy stock Android Browser supports srcdoc from Android 4.4 (KitKat) when Google replaced its WebKit fork with Chromium WebView. Older WebView-based Android Browser builds on Android 4.3 and earlier ignored srcdoc. On modern Android phones, users run Chrome for Android, Firefox for Android, or Samsung Internet, all of which support it.
Internet Explorer never added native support for the iframe srcdoc attribute in any version, including IE 11. Microsoft has retired Internet Explorer, so use Edge 79 or later if you need a Chromium browser on Windows. For pages that still target IE, the jugglinmike srcdoc-polyfill shim reads the attribute and rewrites the iframe to use a data URL instead.
Note: iframe srcdoc behavior changes across older Safari, Edge legacy, and Internet Explorer. Test it on real browsers and OS with TestMu AI. Try TestMu AI free!
The src attribute fetches an external URL into the frame, while srcdoc renders an HTML string the page already contains. Both can appear on the same iframe, in which case srcdoc takes priority and src acts as a fallback for browsers that do not support srcdoc.
| Dimension | iframe srcdoc | iframe src |
|---|---|---|
| Source of content | HTML string written inline in the attribute | URL the browser fetches over the network |
| Network request | None; the HTML is parsed in place | One HTTP request to the target URL |
| Document URL | about:srcdoc | The fetched URL |
| Default origin | Same origin as the parent page (unless sandbox is set) | Origin of the fetched URL |
| Fallback when both are set | Used in browsers that support srcdoc | Used in browsers that do not, including Internet Explorer |
| Best fit | Inline previews, sanitized user HTML, code playgrounds, email rendering | Embedded videos, third-party widgets, separate web apps |
Set srcdoc on an iframe element to a string that contains valid HTML. The browser parses the string as a complete document and renders it inside the frame, with the document URL set to about:srcdoc. You can pair srcdoc with the sandbox attribute to lock down what the embedded code can do, which is the standard pattern for code playgrounds and untrusted HTML previews.
The DOCTYPE, html, head, and body tags are optional inside the srcdoc value, so a one-line snippet is enough for most previews. Quotes inside the value have to be escaped with HTML entities or alternated, and ampersands must be escaped twice when written directly in the markup. Setting the value with element.srcdoc in JavaScript avoids most escaping pain.
Paste this snippet into the browser DevTools console to confirm srcdoc support and render a sandboxed inline document:
// Run in the DevTools console of any browser to test iframe srcdoc support.
const frame = document.createElement("iframe");
const supportsSrcdoc = "srcdoc" in frame;
console.log("iframe srcdoc supported:", supportsSrcdoc);
if (supportsSrcdoc) {
frame.srcdoc = '<!doctype html><meta charset="utf-8"><p>Hello from srcdoc</p>';
frame.sandbox = "allow-scripts";
frame.width = 400;
frame.height = 120;
document.body.appendChild(frame);
}If supportsSrcdoc is false, the browser is Internet Explorer or a very old build. Fall back to a real URL in src or load the jugglinmike srcdoc-polyfill, which converts the attribute to a data URL automatically.
iframe srcdoc has wide modern browser coverage, but a few real edge cases still bite in production. The biggest hits are same-origin behavior, attribute escaping, missing Internet Explorer support, and quirks around relative URLs and Content Security Policy.
In my experience, the most surprising failure happens with relative asset URLs. A srcdoc document that links to /assets/style.css resolves the path against about:srcdoc, which has no host, so the request fails with a network error. Switching to absolute URLs or injecting a base href tag inside the srcdoc HTML fixes it on every browser that supports the attribute.
All iframe srcdoc version numbers and platform notes in this guide come from these primary sources:
Did you find this page helpful?
More Related Hubs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance