HTML <iframe> srcdocAttributes
Examples
An <iframe> with a srcdoc attribute:
<iframe srcdoc="<p>Hello world!</p>" src="demo_iframe_srcdoc.htm"></iframe>
Try it Yourself »
Browser Support
The numbers in the table specify the first browser version that supports the attribute.
| Attributes | |||||
|---|---|---|---|---|---|
| srcdoc | 20.0 | Not supported | 25.0 | 6.0 | 15.0 |
Definition and Usage
The srcdoc attribute specifies the HTML content of the page to show in the inline frame.
Tip:This attribute should be used together with the sandbox and seamless attributes.
If the browser supports the srcdoc attribute, and the srcdoc attribute is specified, it will override the content specified in the src attribute.
If the browser does not support the srcdoc attribute, and the srcdoc attribute is specified, it will display the file specified in the src attribute.
Differences between HTML 4.01 and HTML5
The srcdoc attribute is new in HTML5.
Syntax
<iframe srcdoc="HTML_code">
Attribute Values
| Value | Description |
|---|---|
| HTML_code | The HTML content to display in the iframe. Must be valid HTML syntax. |
HTML <iframe> Tag Other Extensions