An iframe tag, (inline frame) is used to display an external web page on another web page. An iframe is defined using the <iframe> tag.
Syntax
<iframe src="url_of_the_page">
Text to be displayed on browsers that do not support the <iframe> tag.
</iframe>
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML iframe</title>
</head>
<body>
<iframe src="https://www.geekinsta.com">
This browser does not support iframes.
</iframe>
</body>
</head>
Output
Attributes
HTML iframe tag supports the following attributes.
Attribute | Description |
src | Specifies the source of the page to be displayed. |
name | |
width | |
height | |
srcdoc | Specifies the code to be displayed in the |
Example - Specifying height and width
<iframe src="https://www.geekinsta.com" width="200" height="150">
iframe is not supported.
</iframe>
Example - Specifying name
<iframe src="" width="200" height="150" name="myframe">
iframe is not supported.
</iframe>
<a href="myframe" target="myframe">Click Me</a>
Output
Click me to load the pageExample – Using srcdoc attribute
<iframe srcdoc="<p>This is an Iframe</p>"></iframe>
Output
Subscribe
Join the newsletter to get the latest updates.