HTML Tutorial

Chapter: 20



An iframe is used to display a web page within a web page.
This is an example of iframe, is in iframe

Iframe Syntax

An HTML iframe is defined with the <iframe> tag:


<iframe src="URL"></iframe>
The src attribute specifies the URL (web address) of the inline frame page.

Iframe - Set Height and Width

Use the height and width attributes to specify the size of the iframe.
The attribute values are specified in pixels by default, but they can also be in percent (like "80%").


<iframe src="" height="300" width="100%"></iframe>

Iframe - Remove the Border

By default, an iframe has a border around it.
To remove the border, add the style attribute and use the CSS border property:


<iframe src="" style="border:none;"></iframe>
With CSS, you can also change the size, style and color of the iframe's border:


<iframe src="" style="border:2px solid grey;"></iframe>

Iframe - Target for a Link

An iframe can be used as the target frame for a link.
The target attribute of the link must refer to the name attribute of the iframe:


<iframe src="yourpage.html" name="iframe_a"></iframe>
<p><a href="" target="iframe_a"></a></p>
Tag Description
<iframe> Defines an inline frame