An HTML iframe is used to display a web page within a web page.
Example:
HTML
<iframe src="https://itupto.com" title="description"></iframe>
Use the height
and width
attributes to specify the size of the iframe.
Example:
HTML
<!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="https://itupto.com" height="200" width="300" title="Iframe Example"></iframe>
</body>
</html>
Example:
HTML
<iframe src="demo_iframe.htm" style="height:200px;width:300px;" title="Iframe Example"></iframe>
By default, an iframe has a border around it.
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<h2>Remove the Iframe Border</h2>
<p>To remove the default border of the iframe, use CSS:</p>
<iframe src="https://itupto.com" style="border:none;" title="Iframe Example"></iframe>
</body>
</html>
Example:
HTML
<!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="https://itupto.com" style="border:2px solid red;" title="Iframe Example"></iframe>
</body>
</html>
An iframe can be used as the target frame for a link.
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<h2>Iframe - Target for a Link</h2>
<iframe src="https://itupto.com" name="iframe_a" height="300px" width="100%" title="Iframe Example"></iframe>
<p><a href="https://itupto.com" target="iframe_a">Itupto.com</a></p>
<p>When the target attribute of a link matches the name of an iframe, the link will open in the iframe.</p>
</body>
</html>