Tutorials
THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML Iframes

Iframe Syntax

 

An HTML iframe is used for defining the <iframe> tag:

Example

<iframe src="URL"></iframe>

The src attribute is used for specifying the web address or URL of the inline frame page.

Iframe - Set Height and Width

 

The height and width attributes is used to specify the iframe size.

The attribute values are given by default (mentioned in pixels), but specification can also be done in percent (like "80%").

Example

<iframe src="demo_iframe.htm" height="200" width="300"></iframe>
Try it Yourself

Iframe - Remove the Border

 

An iframe has a border around it by default,

For removing the border, you can add the style attribute and make use of the CSS border property:

Example

<iframe src="demo_iframe.htm" style="border:none;"></iframe>
Try it Yourself

Using CSS - the size, style and color of the iframe's border can also be changed:

Example

<iframe src="demo_iframe.htm" style="border:2px solid grey;"></iframe>
Try it Yourself

Iframe - Target for a Link

 

An iframe is used as a link's target frame.

The target attribute of the link refers to the name attribute of the iframe:

Example

<iframe src="demo_iframe.htm" name="iframe_a"></iframe>

<p><a href="http://daks.me" target="iframe_a">ngo.com</a></p>
Try it Yourself

HTML iframe Tag

 
Tag Description
<iframe> Defines an inline frame

Test Yourself with Exercises