Home  >  Article  >  Web Front-end  >  How to specify in HTML the HTML content of a page to be displayed in an

HTML

The

HTML specifies an inline frame. This inline frame is used to embed another document within the current HTML document. This tag is supported by all browsers such as Google Chrome, Microsoft Edge/Internet Explorer, Firefox, Safari, Opera, etc.

The "

srcdoc" attribute of the tag is used to specify the HTML content

Example 1

In the following example, we use the "srcdoc" attribute with the

<!DOCTYPE html>
<html>
<head>
   <title>
      How to specify the HTML content of the page to show in the "iframe" in HTML?
   </title>
</head>
<body>
   <h3>How to specify the HTML content of the page to show in the "iframe" in HTML?</h3>
   <p>We can do it by using <b>srcdoc</b> attribute of iframe in HTML.</p>
   <iframe srcdoc="<h2>You can find any tutorial on tutorialspoint</h2>">
      <p>Browser does not support iframes.</p>
   </iframe>
</body>
</html>

As we can see in the output, the HTML content (

elements) in the document is displayed in

Example 3

By default, all browsers will display

In the example below,

  • We change the style of

  • We use the "srcdoc" attribute with the

<!DOCTYPE html>
<html>
<head>
   <title>
      How to specify the HTML content of the page to show in the "iframe" in HTML?
   </title>
</head>
<body>
   <h3>How to specify the HTML content of the page to show in the "iframe" in HTML?</h3>
   <p>We can do it by using <b>srcdoc</b> attribute of iframe in HTML.</p>
   <iframe srcdoc="<div> Hello Disha</div>" width="50%" height="100" style="border:3px solid green;">
     <p>Browser does not support iframes.</p>
   </iframe>
</body>
</html>

As we can see in the output, the HTML content ( element) in the document is displayed in

The above is the detailed content of How to specify in HTML the HTML content of a page to be displayed in an