Summary -
In this topic, we described about the <iframe> tag along with detailed example.
Nested browsing context or inline frame. The <iframe> used to represent inline frame. The inline frame allows embedding one HTML document in another HTML document.
The tag can be specified like <iframe src=""></iframe> with the URL of the embedded document in between the opening/closing quotes.
Optional Attributes -
Attribute | Description | Values |
---|---|---|
align | Specifies the alignment of the <iframe>Not supported in HTML5 | LeftRightTopBottom |
Frameborder | Specifies the border display needed or not.Not supported in HTML5 | 01 |
Height | Specifies the height of <iframe> | Pixels |
Marginheight | Specifies the top and bottom margins of the iframe.Not supported in HTML5 | Pixels |
Marginwidth | Specifies the left and right margins of the iframe.Not supported in HTML5 | Pixels |
Name | Specifies the name of the iframe | Text |
sandbox | Specifies a set of restriction to the content of <iframe>.HTML5 attribute | allow-formsallow-pointer-lockallow-popupsallow-same-originallow-scriptsallow-top-navigation |
Scrolling | Specifies frame defined is scrollable or not.Not supported in HTML5 | Auto NoYes |
src | Specifies the address of the webpage embedded. | URL. |
srcdoc | Specifies the HTML content code to show in <iframe>.HTML5 attribute | HTML. |
width | Specifies the width of the <iframe> | Pixels |
Syntax -
<iframe>.. text here.. </iframe>
Example -
<!DOCTYPE html>
<html>
<head>
<title>Italic text example.. </title>
</head>
<body>
<iframe src="https://www.tutorialscampus.com">
<p>Browser does not support iframes.</p>
</iframe>
</body>
</html>