The HTML <iframe> tag defines an inline frame, which is used to embed another HTML document within the current page.
The height and width are specified in pixels by default:
<iframe>?width, height, and frameborder="0" attributes on the <iframe> tag.<!DOCTYPE html> <html> <head> <title>Custom Iframe Dimensions</title> </head> <body> <h3>Embedded Content Preview</h3> <table border="2" bordercolor="#007bff" width="100%"> <tr> <td> <iframe src="demo_iframe.html" width="100%" height="250" frameborder="0" title="Custom Frame"> </iframe> </td> </tr> </table> </body> </html>
|
This page is displayed in an iframe
|
frameborder="0" attribute removes the default grey border of the iframe, while wrapping it inside a <table> provides a custom colored border around the frame content.
<iframe> when clicked?name attribute of the <iframe> with the target attribute of the <a> tag.<!DOCTYPE html> <html> <head> <title>Iframe Target Example</title> </head> <body> <h3>Interactive Content Viewer</h3> <iframe src="demo_iframe.html" name="content_frame" height="200px" width="100%" title="Target Frame"> </iframe> <p> Click here: <a href="https://aitaurangabad.com/" target="content_frame">Open aitaurangabad Website</a> </p> </body> </html>
target attribute of an anchor tag matches the name attribute of an iframe, clicking the link loads the new webpage inside that iframe instead of opening a new tab.