Summary -

In this topic, we described about the iframes 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.

Syntax -

<iframe>.. text here.. </iframe>

Optional Attributes -

AttributeDescriptionValues
alignSpecifies the alignment of the <iframe>Not supported in HTML5.LeftRightTopBottom
FrameborderSpecifies the border display needed or not.Not supported in HTML5.01
HeightSpecifies the height of <iframe> Pixels
MarginheightSpecifies the top and bottom margins of the iframe.Not supported in HTML5.Pixels
MarginwidthSpecifies the left and right margins of the iframe.Not supported in HTML5.Pixels
NameSpecifies the name of the iframeText
sandboxSpecifies a set of restriction to the content of <iframe>.Newly added in HTML5.allow-formsallow-pointer-lockallow-popupsallow-same-originallow-scriptsallow-top-navigatio
ScrollingSpecifies frame defined is scrollable or notNot supported in HTML5.Auto NoYes
srcSpecifies the address of the webpage embedded.URL.
srcdocSpecifies the HTML content code to show in <iframe>.Newly added in HTML5.HTML.
widthSpecifies the width of the <iframe>Pixels

Example -

<!DOCTYPE html>
<html>
<head>
	<title>Italic text example.. </title>
</head>
<body>
	<iframe src="https://www.tutorialscampus.com" width="100%" height="450">
		<p>Browser does not support iframes.</p>
	</iframe>
</body>
</html>

Output -