HTML <iframe> Tag

Description

The <iframe> HTML element creates a built-in frame that is inside a regular document, it allows you to load any other independent documents into the set size area.
<iframe> is a container whose contents are ignored by browsers that do not support this element. For these browsers, you can specify alternative text that users see. It should be between the <iframe> and </iframe> tags.

Properties

Permitted Parents
Any element that accepts embedded content
Content
Any block, inline and text
Start/End Tags
Start tag: required, End tag: required

Example

<iframe id="I1" name="I1" src="images/sunset.jpg">Your 
browser does not support inline frames or is currently
configured not to display inline frames.</iframe>

Attributes

Attribute Definition
name Assigns a name to a frame. This is useful for loading contents into one frame from another.
longdesc A long description - this can elaborate on a shorter description specified with the title attribute.
width Specifies the width of the inline frame.
height Specifies the height of the inline frame.
src Location of the frame contents (for example, the HTML page to be loaded into the frame).
scrolling Whether the frame should be scrollable or not (i.e. should scrollbars appear).
Possible values:
  • auto
  • yes
  • no
frameborder Whether the frame should have a border or not.
Possible values:
  • 1 (border)
  • 0 (no border)
marginwidth Specifies the margin, in pixels, between the frame's contents and it's left and right margins.
marginheight Specifies the margin, in pixels, between the frame's contents and it's top and bottom margins.
align

Specifies the alignment.
Possible Values:

  • left
  • right
  • center
  • justify

Global Attributes

The <iframe> tag also supports the Global Attributes in HTML5

Event Attributes

The <iframe> tag also supports the Event Attributes in HTML5

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
YesYes1YesYesYes
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYesYesYesYesYes

Last updated by CSSPortal on: 6th December 2019