Search This Blog

Wednesday, 1 January 2014

1.21 HTML Iframes

An iframe is used to display a web page within a web page.

Syntax for adding an iframe:
<iframe src="URL"></iframe>

The URL points to the location of the separate page.

Iframe - Set Height and Width

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

<iframe src="demo_iframe.htm" width="200" height="200"></iframe>
Example:
<!DOCTYPE html>
<html>
<body>

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

<p>Some older browsers don't support iframes.</p>
<p>If they don't, the iframe will not be visible.</p>

</body>
</html>

Use iframe as a Target for a Link

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

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

Example:

<!DOCTYPE html>
<html>
<body>

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

<p><b>Note:</b> Because the target of the link matches the name of the iframe, the link will open in the iframe.</p>

</body>
</html>


Tag                      Description
<iframe>              Defines an inline frame


No comments:

Post a Comment