HTML Tags

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:

HTML / XHTML: <iframe src="URL" scrolling="auto|no|yes"> ... </iframe>

The example below shows the <iframe> tag in action.

<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
right
top
middle
bottom
Obsolete Specifies the alignment of an iframe with respect to the surrounding elements.
frameborder 1
0
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
allow-pointer-lock
allow-popups
allow-same-origin
allow-scripts
allow-top-navigation
Enables extra restrictions on the content that can appear in the iframe.
scrolling yes
no
auto
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.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 3+
  • Apple Safari 1+
  • Opera 5+

Further Reading

See tutorial on: HTML Iframes.

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties