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.
The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati
The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.
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.
The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159
The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.
The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex