Tag <iframe> HTML Reference



Example

An inline frame is marked up as follows:

<iframe src="http://www.google.com"></iframe>

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

1. Definition and Usage

The <iframe> tag specifies an inline frame.

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


2. Tips and Notes

Tip: To deal with browsers that do not support <iframe>, place the text you want between the opening <iframe> tag and the closing </iframe> tag.


3. Differences Between HTML and XHTML

In XHTML, the name attribute of the <iframe> tag is deprecated, and will be removed. Use the id attribute instead.


4. Optional Attributes

DTD indicates in which HTML 4.01/XHTML 1.0 DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.

AttributeValueDescriptionDTD
alignleft
right
top
middle
bottom
Deprecated. Use styles instead.
Specifies the alignment of an <iframe> according to surrounding elements
TF
frameborder1
0
Specifies whether or not to display a border around an <iframe>TF
heightpixels
%
Specifies the height of an <iframe>TF
longdescURLSpecifies a page that contains a long description of the content of an <iframe>TF
marginheightpixelsSpecifies the top and bottom margins of the content of an <iframe>TF
marginwidthpixelsSpecifies the left and right margins of the content of an <iframe>TF
namenameSpecifies the name of an <iframe>TF
scrollingyes
no
auto
Specifies whether or not to display scrollbars in an <iframe>TF
srcURLSpecifies the address of the document to embed in the <iframe>TF
widthpixels
%
Specifies the width of an <iframe>TF

5. Standard Attributes

The <iframe> tag supports the following standard attributes:

AttributeValueDescriptionDTD
classclassnameSpecifies a classname for an elementTF
ididSpecifies a unique id for an elementTF
stylestyle_definitionSpecifies an inline style for an elementTF
titletextSpecifies extra information about an elementTF

6. Event Attributes

According to the W3C, the <iframe> tag does not support any event attributes.

However, the onload event is supported in all browsers.


Relative articles