An HTML iframe is used to display a web page within a web page.
The HTML <iframe> element is used to display another webpage inside the current webpage.
An iframe creates an inline frame that loads external content such as another HTML page, a website, a video, or other resources within your page layout.
<iframe src="URL" title="Description"> </iframe>
src → Specifies the URL of the page you want to display.
title → Provides a description of the iframe content (important for accessibility).
It is strongly recommended to always include the title attribute. Screen readers use it to describe the iframe content to users.
You can control the size of an iframe using either HTML attributes or CSS.
<iframe src="page.html" height="200" width="300" title="Example Iframe"> </iframe>
By default, height and width values are measured in pixels.
< iframe src="page.html" style="height:200px; width:300px;" title="Example Iframe" > </iframe>
Using CSS gives you more flexibility for styling and responsiveness.
By default, most browsers display a border around an iframe.
To remove it, use CSS:
< iframe src="page.html" style="border:none;" title="Example Iframe" > </iframe>
An iframe can display content when a link is clicked.
First, give the iframe a name attribute:
< iframe src="page.html" name="myFrame" title="Example Iframe" > </iframe>
Then, set the links target attribute to match that name:
< a href="https://LeranHTML.edu" target="myFrame" > Open Website </a>
When the link is clicked, the webpage will open inside the iframe instead of replacing the current page.
<iframe> is used to embed another webpage inside your page.
The src attribute defines the URL of the embedded content.
Always include the title attribute for accessibility.
Use height and width to control size.
Use border:none; to remove the default border.
The name attribute allows the iframe to act as a target for links.