HTML5 IFRAMES CHAPTER 15
15th TUTORIAL ON HTML IFRAMES
HTML Iframes
An HTML
iframe is used to display a web page within a web page.
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 height and width are specified in pixels by default:
Example
<!DOCTYPE html>
<html>
<body>
<h2>HTML Iframes</h2>
<p>You can use the height and width attributes to specify the size of
the iframe:</p>
<iframe src="demo_iframe.htm" height="200"
width="300"></iframe>
</body>
</html>
OUTPUT
HTML Iframes
You can use the height and
width attributes to specify the size of the iframe:
This page is displayed in an 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:
<!DOCTYPE html>
<html>
<body>
<h2>Remove the Iframe Border</h2>
<p>To remove the default border of the iframe, use CSS:</p>
<iframe src="demo_iframe.htm"
style="border:none;"></iframe>
</body>
</html>
OUTPUT
Remove the Iframe
Border
To remove the default border of the iframe, use
CSS:
This page is
displayed in an iframe
|
With CSS, you can also
change the size, style and color of the iframe's border:
<!DOCTYPE html>
<html>
<body>
<h2>Custom Iframe Border</h2>
<p>With CSS, you can also change the size, style and color of the
iframe's border:</p>
<iframe src="demo_iframe.htm" style="border:2px solid
red;"></iframe>
</body>
</html>
OUTPUT
Custom Iframe Border
With CSS, you can also change the
size, style and color of the iframe's border:
This page is
displayed in an 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:
<!DOCTYPE html>
<html>
<body>
<h2>Iframe - Target for a Link</h2>
<iframe height="300px" width="100%"
src="demo_iframe.htm" name="iframe_a"></iframe>
<p><a href="https://www.w3schools.com"
target="iframe_a">W3Schools.com</a></p>
<p>When the target of a link matches the name of an iframe, the link
will open in the iframe.</p>
</body>
</html>
OUTPUT
Iframe -
Target for a Link
This page is
displayed in an iframe
|
When the target of a link matches the name of an
iframe, the link will open in the iframe
Comments
Post a Comment