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 -

AttributeDescriptionValues
alignSpecifies the alignment of the <iframe>Not supported in HTML5LeftRightTopBottom
FrameborderSpecifies the border display needed or not.Not supported in HTML501
HeightSpecifies the height of <iframe>Pixels
MarginheightSpecifies the top and bottom margins of the iframe.Not supported in HTML5Pixels
MarginwidthSpecifies the left and right margins of the iframe.Not supported in HTML5Pixels
NameSpecifies the name of the iframeText
sandboxSpecifies a set of restriction to the content of <iframe>.HTML5 attributeallow-formsallow-pointer-lockallow-popupsallow-same-originallow-scriptsallow-top-navigation
ScrollingSpecifies frame defined is scrollable or not.Not supported in HTML5Auto NoYes
srcSpecifies the address of the webpage embedded.URL.
srcdocSpecifies the HTML content code to show in <iframe>.HTML5 attributeHTML.
widthSpecifies 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>

Output -