HTML <iframe>
Tag
Topic: HTML5 Tags ReferencePrev|Next
Description
The <iframe>
(short for inline frame) tag defines an inline frame that contains external objects including other web page.
The following table summarizes the usages context and the version history of this tag.
Placement: | Block |
---|---|
Content: | Any block, inline, and text |
Start/End Tag: | Start tag: required, End tag: required |
Version: | HTML 4, 5 |
Syntax
The basic syntax of the <iframe>
tag is given with:
The example below shows the <iframe>
tag in action.
Example
Try this code »<iframe src="hello.html" width="400" height="300" scrolling="auto">
<p>[Your browser does not support frames or is currently configured not to display frames. However, you may visit <a href="optional.html">the related document.</a>]</p>
</iframe>
Tag-Specific Attributes
The following table shows the attributes that are specific to the <iframe>
tag.
Attribute | Value | Description |
---|---|---|
align |
left |
Obsolete Specifies the alignment of an iframe with respect to the surrounding elements. |
frameborder |
1 |
Obsolete Instructs the browser whether or not to display a border around the iframe. |
height |
length | Specifies the height of the iframe. |
longdesc |
URL | Obsolete Specifies a link to a long description of the iframe. |
marginheight |
pixels | Obsolete Specifies the amount of space (in pixels) between the top and bottom edges of the iframe and its contents. |
marginwidth |
pixels | Obsolete Specifies the amount of space (in pixels) between the left and right edges of the iframe and its contents. |
name |
text | Assigns a name to the iframe to be referenced by targeted links. |
sandbox |
allow-forms |
Enables extra restrictions on the content that can appear in the iframe. |
scrolling |
yes |
Obsolete Specifies whether or not scroll bars appear in the iframe. |
seamless |
seamless |
This Boolean attribute specifies that the iframe should appear as a part of the containing document. |
src |
URL | Specifies the location of the document to be embedded inside the iframe. |
srcdoc |
HTML-code | Specifies the HTML content of the page to embed in the iframe. This attribute will override the content specified in the src attribute, if present. |
width |
length | Specifies the width of the iframe. |
Global Attributes
Like all other HTML tags, the <iframe>
tag supports the global attributes in HTML5.
Event Attributes
The <iframe>
tag also supports the event attributes in HTML5.
Browser Compatibility
The <iframe>
tag is supported in all major modern browsers.
Basic Support—
|
Further Reading
See tutorial on: HTML Iframes.