HTML | srcdoc Attribute

The HTML srcdoc attribute is used to specify the HTML content of the page to show in the inline frame. This attribute is anticipated to be used beside the sandbox and seamless attributes.
If a browser supports the srcdoc attribute, it’ll override the content laid out in the src attribute (if present).
If a browser doesn’t support the srcdoc attribute, it’ll show the file laid out in the src attribute instead (if present).

Supported tag:

  • iframe

Example:



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<body>
    <center>
        <h1 style="color:green">GeeksforGeeks</h1>
        <iframe srcdoc="<h3>I am inside iframe.</h3>" 
                src="https://ide.geeksforgeeks.org/tryit.php">
        </iframe>
    </center>
</body>
  
</html>

chevron_right


Output:

Supported Browsers: The browsers supported by HTML srcdoc Attribute are listed below:

  • Google Chrome
  • Firefox
  • Apple Safari
  • Opera


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.