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.

HTML5

“iframe” is supported in html5.

Here's a iframe sample:

Here's the code:

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

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>

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

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. Visual CSS
  3. JS in Depth
  4. JS Reference
  5. DOM
  6. SVG
  7. Web Dev Blog