HTML: iframe

By Xah Lee. Date: . Last updated: .

What is Iframe

Iframe is used to embed another page's content in the current page, and it can also be used to create a scrollable window inside a window.

Iframe Example

Code

<iframe src="xyz.html" width="200" height="300"></iframe>

Iframe Attributes

src

source url

name

a name string for the frame

longdesc

a url

width

integer (pixels)

height

integer (pixels)

align

One of: top, middle, bottom, left, right

frameborder

1 or 0

marginwidth

integer (pixels)

marginheight

integer (pixels)

scrolling

yes, no, auto

Control Iframe Appearance

HTML 4.01 transitional

If you are using HTML 4.01 transitional, or XHTML 1.1 transitional , you can use iframe like this:

<iframe src="some.html"
 longdesc="iframe_longdesc.html"
 width="200"
 height="200"
 align="top"
 frameborder="1"
 scrolling="auto">
For browsers that doesn't support iframe, this text is displayed.
</iframe>

HTML 4.01 Strict

“Iframe” tag is not supported in HTML 4.01 Strict nor XHTML 1.1 Strict.

However, all browsers supports it anyway.

To be technically correct, you can use “object” tag. See:

HTML: Object Tag