HTML Attributes
HTML srcdoc attribute
Supplies inline HTML for an iframe and takes precedence over src. Treat untrusted markup as dangerous; use a restrictive sandbox and sanitize as appropriate. Applicable elements include: <iframe>. Check each element’s value rules.
Formal Syntax & Structure
html syntaxhtml
srcdoc="<p>Hello</p>"Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| srcdoc | HTML document text | Supplies inline HTML for an iframe and takes precedence over src. Treat untrusted markup as dangerous; use a restrictive sandbox and sanitize as appropriate. |
Working Example
Example Snippethtml
<iframe title="Example" sandbox srcdoc="<p>Hello</p>"></iframe>Browser Compatibility
Minimum supported versions across modern rendering engines
Chrome
20
Yes
Firefox
25
Yes
Safari
6
Yes
Checked desktop BCD snapshot: iframe srcdoc. Versions denote the recorded start of support (≤ means at least that early), not a guarantee of all behavior. Unresolved mirror and preview rows omitted.
HTML Living Standard