English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag Encyclopedia

HTML: <iframe> tag

The HTML <iframe> tag allows you to embed another HTML page into the current page. This tag is also commonly referred to as the <iframe> element.

Online Examples

Mark an inline frame:

!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>Basic Tutorial(oldtoolbag.com)</title> 
</head> 
<body>
<iframe src="//www.oldtoolbag.com">
  <p>Sorry, your browser does not support iframe </p>
</iframe>
</body>
</html>
Test to see ‹/›

If the browser does not support the <iframe> tag, it will display the text 'Sorry, your browser does not support iframe' as an alternative.

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the <iframe> tag.

Definition and Usage

<iframe> tag defines an inline frame.

An inline frame is used to embed another document within the current HTML document.

Within the frame, scripts can use window.parent to refer to the parent window.

Tips and Notes

Tip:You can place the required text between <iframe> and </between <iframe> tags, so that it can handle browsers that do not support <iframe>.

Tip:Use CSS to define styles for <iframe> (including scrollbars).

HTML 4.01 with HTML5differences

HTML5 New properties have been added, and some have been removed in HTML 4.01 Some properties.

Differences between HTML and XHTML

In XHTML, the name attribute has been deprecated and will be removed. Please use the id attribute instead.

Attribute

New : HTML5 New attribute added to the .

AttributeValueDescription
alignleft
right
top
middle
bottom
HTML5 Not supported. HTML 4.01 Deprecated.    Define how to align the <iframe> relative to the surrounding elements.
frameborder1
 0
HTML5 Not supported. Define whether to display a border around the <iframe>.
heightpixelsSpecify the height of the <iframe>.
longdescURLHTML5 Not supported. Define a page that contains a longer description of the <iframe>.
marginheightpixelsHTML5 Not supported. Specify the top and bottom margins of the <iframe>.
marginwidthpixelsHTML5 Not supported. Specify the left and right margins of the <iframe>.
namenameSpecify the name of <iframe>.
sandboxHTML5""
 allow-forms
 allow-same-origin
 allow-scripts
 allow-top-navigation
Define a series of additional restrictions on the content of <iframe>.
scrollingyes
 no
 auto
HTML5 Not supported. Specify whether to display scrollbars in the <iframe>.
seamlessHTML5seamlessSpecify that the <iframe> appears to be part of the parent document.
srcURLSpecify the URL of the document displayed in the <iframe>.
srcdocHTML5HTML_codeSpecify the HTML content displayed in the <iframe> on the page.
widthpixelsSpecify the width of <iframe>.

Global Attributes

Supports <iframe> tag Global Attributes of HTML.

Event Attributes

Supports <iframe> tag HTML Event Attributes.

Related Articles

HTML Tutorial:HTML Frames

HTML DOM Reference Manual:IFrame Object