HTML Iframe

Iframe is used to display web pages within a web page.

Syntax for adding an iframe

<iframe src="URL</iframe>

URL Point to the location of an isolated page.

Iframe - Set Height and Width

The height and width attributes are used to specify the height and width of the iframe.

The default unit of the attribute value is pixels, but it can also be set using percentages (e.g., "80%").

Example

<iframe src="demo_iframe.htm" width="200" height="200"></iframe>

Try It Yourself

Iframe - Remove Border

The frameborder attribute specifies whether to display the border around the iframe.

Setting the attribute value to "0" can remove the border:

Example

<iframe src="demo_iframe.htm" frameborder="0"></iframe>

Try It Yourself

Using iframes as the target of links

Iframes can be used as the target (target) of links.

The target attribute of the link must refer to the name attribute of the iframe:

Example

<iframe src="demo_iframe.htm" name="iframe_a"</iframe>
<p><a href="http://www.codew3c.com" target="iframe_a">codew3c.com</a></p>

Try It Yourself

HTML iframe Tag

Tag Description
<iframe> Define an inline sub-window (frame)