HTML <iframe> srcdoc eigenschap
Definition and usage
srcdoc
The attribute specifies the HTML content of the page to be displayed in the inline frame.
Tip:This attribute is expected to be used with sandbox
and seamless
attribute together.
If the browser supports srcdoc
attribute, it will override the content specified in the src attribute (if it exists).
If the browser does not support srcdoc
If the attribute is not set, it will display the file specified in the src attribute (if it exists).
Example
iframe with srcdoc attribute set:
<iframe srcdoc="<p>Hello world!</p>" src="demo_iframe_srcdoc.html"></iframe>
Syntax
<iframe srcdoc="HTML_code">
Attribute value
Value | Description |
---|---|
HTML_code | HTML content displayed in iframe. It must be valid HTML syntax. |
Browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
20.0 | 79.0 | 25.0 | 6.0 | 15.0 |