The srcdoc attribute on an <iframe> tag specifies HTML content to embed in the iframe.
It‘s a way to directly specify the HTML that goes into the iframe.
A srcdoc attribute on an <iframe> element.
The specified srcdoc value, which is HTML, is displayed in the frame.
<iframe style="width:100%;height:100px;" src="/tutorial/order.html"
srcdoc="<h3>Order Received</h3>
<p>Order details will be emailed shortly.</p>">
</iframe>
The scrdoc attribute places HTML content (HTML code) inside the iframe.
This attribute provides the ability to specify iframe content without an external source.
If the iframe also has a src attribute, then scrdoc will override it.
If the browser does not support scrdoc, then the src value will be used.
<iframe srcdoc="HTML-code" />
| Value | Description |
|---|---|
| HTML-code | Valid HTML code to be displayed inside the iframe element. |
Here is when srcdoc support started for each browser:
![]() Chrome
|
20.0 | Jun 2012 |
![]() Firefox
|
25.0 | Oct 2013 |
![]() IE/Edge
|
79.0 | Jan 2020 |
![]() Opera
|
15.0 | May 2013 |
![]() Safari
|
6.0 | Jul 2012 |