HTML: Iframe

By Xah Lee. Date: . Last updated: .

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.

Here is a iframe sample:

Here is the 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

Iframe Appearance

To control iframe appearance, use CSS.

[see CSS: OverFlow, Scrollbar]

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: using Object tag for Iframe

See also: HTML: Frameset to Split Windows

JS in Depth
XAH  BUY NOW

HTML Basics

HTML Table

Misc

HTML4 Frameset