HTML srcdoc Attribute

HTML srcdoc Attribute: This attribute specifies the HTML content of the page to show in the inline frame. This attribute is expected to be used together with the sandbox and seamless attributes. And if a browser supports the srcdoc attribute, it will override the content specified in the src attribute. In case if a browser does NOT support the srcdoc attribute, it will show the file specified in the src attribute instead.

HTML srcdoc Attribute

This attribute can be applied on <iframe> element.

Browser Support

This attribute is supported by the following browsers:

  • Chrome
  • Firefox
  • Opera
  • Safari
  • Internet Explorer

Example: for <iframe> element

<!DOCTYPE html>
<iframe srcdoc="<p>Hello world!</p>" src="demo_iframe_srcdoc.htm">
  <p>Your browser does not support iframes.</p>

HTML srcdoc attribute