NOTICE: This website is no longer updated or supported - as such many of the techniques used to build it may seem antiquated in the modern day. It is preserved for historical reasons only.

HTML XHTML The Complete Reference
home » reference » appendix a » html element reference

<iframe> (Floating Frame)


This element indicates a floating frame, an independently controllable content region that can be embedded in a page.

Standard Syntax (Transitional and Frameset Only)


<iframe
align="bottom | left | middle | right | top"
class="class name(s)"
dir="ltr | rtl"
frameborder="1 | 0"
height="percentage | pixels"
id="unique alphanumeric identifier"
lang="language code"
longdesc="url of description"
marginheight="pixels"
marginwidth="pixels"
name="string"
scrolling="auto | no | yes"
src="url of frame contents"
style="style information"
title="advisory text"
width="percentage | pixels"
</iframe>

Attributes Defined by Internet Explorer 4


allowtransparency="false | true" (5.5)
application="yes" (5)
border="pixels" (4)
bordercolor="color name | #RRGGBB" (4)
datafld="name of column supplying bound data" (4)
datasrc="id of data source object supplying data" (4)
frameborder="no | yes | 0 | 1" (4)
hidefocus="true | false" (5.5)
hspace="pixels" (4)
language="javascript | jscript | vbs | vbscript" (4)
security="restricted" (6)
tabindex="number" (5.5)
unselectable="on | off" (5.5)
vspace="pixels" (4)

Standard Event Attributes


onclick, ondblclick, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup

Events Defined by Internet Explorer


onactivate, onafterupdate, onbeforedeactivate, onbeforeupdate, onblur, oncontrolselect, ondeactivate, onerrorupdate, onfocus, onload, onmove, onmoveend, onmovestart, onreadystatechange, onresizeend, onresizestart, ontimeerror

Element Specific Attributes


align
This attribute controls the horizontal alignment of the floating frame with respect to the page. The default is left.

allowtransparency
This Internet Explorer–specific attribute determines whether the <iframe> is transparent or opaque. The default value is false, which means it is opaque.

application
This Microsoft-specific attribute is used to indicate whether the contents of an <iframe> are to be considered an HTA application. HTA applications are applications that use HTML, JavaScript, and Internet Explorer, but are not limited to the typical type of security considerations of a Web page. Given its security implications, this attribute should only be set if the developer is familiar with HTAs.
border
This attribute specifies the thickness of the border in pixels.

bordercolor
This attribute specifies the color of the border.

datafld
This attribute specifies the column name from the data source object that supplies the bound data.

datasrc
This attribute indicates id of the data source object that supplies the data that is bound to this element.

frameborder
This attribute determines whether the frame is surrounded by a border. The HTML 4 specification defines 0 to be off and 1 to be on. The default value is 1. Internet Explorer also defines the values no and yes.

framespacing
This attribute creates additional space between the frames.

height
The attribute sets the floating frame's height in pixels.

hspace
This attribute specifies margins for the frame.

longdesc
This attribute specifies a URL of a document which contains a long description of the frame's contents. This might be particularly useful as a complement to the <title> element.

marginheight
This attribute sets the height in pixels between the floating frame's content and its top and bottom borders.

marginwidth
This attribute sets the width in pixels between the floating frame's content and its left and right borders.

name
This attribute assigns the floating frame a name so that it can be the target destination of hyperlinks.

scrolling
This attribute determines if the frame has scroll bars. A yes value forces scroll bars; a no value prohibits them.

security
This attribute sets the value indicating whether the source file of an iframe has security restrictions applied. The only allowed value is restricted.
src
This attribute contains the URL of the content to be displayed in the floating frame. If absent, the frame is blank.

vspace
This attribute specifies margins for the frame.

width
This attribute sets the floating frame's width in pixels.

Example


<iframe src="http://www.democompany.com" height="150"
   width="200" name="FloatingFrame1">

Sorry, your browser doesn't support inline frames.
</iframe>

Compatibility


HTML 4 (transitional)
XHTML 1.0 (transitional or frameset)
Internet Explorer 3, 4, 5, 5.5, 6
Netscape 6, 7
Opera 5-7

Notes


Under the HTML 4 strict specification, the iframe element is not defined. However, under XHTML transitional and XHTML frameset, iframe is allowed. XHTML 1.1 does not allow it either. Floating frames can be somewhat imitated using the div element and CSS positioning facilities.

When a browser does not understand an <iframe> tag, it displays the text included within it as an alternate rendering.

(X)HTML Elements
CSS Properties
Previous: i Next: ilayer
< Home | About | Chapters | Examples | Errata | Reference | Site Map >