Widely availableUseful when isolation is needed, but it should be used deliberately because it adds performance, interaction, and accessibility complexity.

Overview

The <iframe> element embeds another HTML page or document inside the current page. It is useful for isolated embeds, external content, and sandboxed previews.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
1
12
1
≤4
18
≤3.2
HTML attribute
height
1
12
1
3
18
2
name
1
12
1
3
18
2
src
1
12
1
≤4
18
≤3.2
width
1
12
1
3
18
2
DOM API

The HTMLIFrameElement interface provides special properties and methods (beyond those of the HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of inline frame elements.

1
12
1
3
18
1

If the iframe and the iframe's parent document are Same Origin, returns a Document (that is, the active document in the inline frame's nested browsing context), else returns null.

1
12
1
3
18
1

The contentWindow property returns the Window object of an HTMLIFrameElement.

1
12
1
3
18
1

The getSVGDocument() method of the HTMLIFrameElement interface returns the Document object of the embedded SVG.

1
12
3.5
3.1
18
2

The height property of the HTMLIFrameElement interface returns a string that reflects the height attribute of the iframe element, indicating the height of the frame in CSS pixels.

1
12
1
3
18
1

The name property of the HTMLIFrameElement interface is a string value that reflects the name attribute of the iframe element, indicating the specific name of the element.

1
12
1
3
18
1

The HTMLIFrameElement.src A string that reflects the src HTML attribute, containing the address of the content to be embedded.

1
12
1
3
18
1

The width property of the HTMLIFrameElement interface returns a string that reflects the width attribute of the iframe element, indicating the width of the frame in CSS pixels.

1
12
1
3
18
1
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Notes 1 item(s)
Implementation note
  • The `resize` CSS property doesn't have any effect on this element due to bug 680823.
Notes 1 item(s)
Implementation note
  • Safari has a bug that prevents iframes from loading if the `iframe` element was hidden when added to the page. `iframeElement.src = iframeElement.src` should cause it to load the iframe.
Notes 1 item(s)
Implementation note
  • Safari on iOS has a bug that prevents iframes from loading if the `iframe` element was hidden when added to the page. `iframeElement.src = iframeElement.src` should cause it to load the iframe.

Syntax

HTML
<iframe src="https://example.com"
  width="600" height="400"
  title="外部コンテンツ"
  loading="lazy"
  sandbox="allow-scripts allow-same-origin">
</iframe>

Live demo

basic Iframe

Iframe insideinline HTML fill. with srcdoc

PreviewFullscreen

iframe Sizecontrol

Responsive iframe create. with Width / height and CSS.

PreviewFullscreen

Title attribute. heavymain

Iframe to is title attribute in content. Description provide(akseshiriti).

PreviewFullscreen

Use cases

  • Embedded tools

    Host external widgets, maps, or previews that need a separate document context.

  • Sandboxed content

    Isolate untrusted or separately managed content in its own browsing context.

Cautions

  • Iframes can create keyboard, sizing, and loading complexity, especially when many are stacked on one page.
  • Cross-origin embeds may limit styling, scripting, and direct interaction in ways that must be planned for explicitly.

Accessibility

  • Give each iframe a clear title so users understand what embedded content they are entering before focus moves inside it.

Powered by web-features