In this article, we need to display the HTML content of the page in an iframe; the browser window is divided into separate pages. We can accomplish this using the
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 tag to specify the HTML content of the page ( element) to be displayed in
of the HTML.
<!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 id="How-to-specify-the-HTML-content-of-the-page-to-show-in-the-iframe-in-HTML">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 id="You-can-find-any-tutorial-on-tutorialspoint">You can find any tutorial on tutorialspoint</h2>">
<p>Browser does not support iframes.</p>
</iframe>
</body>
</html>
Copy after login
As we can see in the output, the HTML content (
elements) in the document is displayed in .
Example 2
Here is another example of HTML Iframe, here we create a table inside the iframe.
<!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 id="How-to-specify-the-HTML-content-of-the-page-to-show-in-the-iframe-in-HTML">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="<table border = 3>
<caption> Abbreviations </caption>
<tr>
<th> HTML </th>
<th> CSS </th>
</tr>
<tr>
<td> Hypertext markup language</td>
<td> Cascading style sheet </td>
</tr>
</table>">
<p>Browser does not support iframes.</p>
</iframe>
</body>
</html>
Copy after login
As we can see in the output, the HTML content (HTML table) in the document is displayed in .
Example 3
By default, all browsers will display as the default. We can use CSS to change the style of .
In the example below,
We change the style of by changing its width, height, and borders using CSS.
We use the "srcdoc" attribute with the tag to specify the HTML content of the page (element) to be displayed in in the HTML.
<!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 id="How-to-specify-the-HTML-content-of-the-page-to-show-in-the-iframe-in-HTML">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>
Copy after login
As we can see in the output, the HTML content ( element) in the document is displayed in , and we also changed the style of using CSS.
The above is the detailed content of How to specify in HTML the HTML content of a page to be displayed in an ?. For more information, please follow other related articles on the PHP Chinese website!
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.
HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.
To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...
HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.
The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...