Sometimes, we want to specify content of an iframe instead of the src attribute to a page with HTML.
In this article, we’ll look at how to specify content of an iframe instead of the src attribute to a page with HTML.
How to specify content of an iframe instead of the src attribute to a page with HTML?
To specify content of an iframe instead of the src attribute to a page with HTML, we set the srcdoc attribute.
For instance, we write
<iframe srcdoc="<p>Hello world!</p>" src="frame.htm"></iframe>
to set the iframe’s srcdoc attribute to the HTML we want to render.
Conclusion
To specify content of an iframe instead of the src attribute to a page with HTML, we set the srcdoc attribute.