English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The srcdoc attribute specifies the HTML content of the page to be displayed inline in the iframe, and the srcdoc attribute should be used with the sandbox and seamless attributes
An <iframe> with a srcdoc attribute:
<!DOCTYPE html> <html> <head> <title>HTML: <iframe> srcdoc attribute - 基础教程网 oldtoolbag.com</title> <body> <iframe srcdoc="<p>Hello world!</p>/p>" src="demo-iframe.html"> <p>Your browser does not support iframes.</p>/p> </iframe> </body> </html>Test see ‹/›
The numbers in the table indicate the first browser version number that supports the attribute.
Attribute | |||||
---|---|---|---|---|---|
srcdoc | 20.0 | Not supported | 25.0 | 6.0 | 15.0 |
The srcdoc attribute specifies the HTML content of the page to be displayed in the inline frame.
Tip:The srcdoc attribute should be used with the sandbox and seamless attributes.
If the browser supports the srcdoc attribute, it will override the content specified in the src attribute (if it exists).
If the browser does not support the srcdoc attribute, it will display the file specified in the src attribute (if it exists).
The srcdoc attribute is an HTML5 New attributes added in.
<iframe srcdoc="HTML_code">
Value | Description |
---|---|
HTML_code | HTML content is displayed in iframe. It must be valid HTML syntax. |