How to specify content of an iframe instead of the src attribute to a page with HTML?

Spread the love

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.

Leave a Reply

Your email address will not be published. Required fields are marked *