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's a iframe sample:

Here's 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: Split Windows; Frameset

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. CSS
  3. JavaScript
  4. JS Obj Ref
  5. DOM
  6. SVG
  7. Blog