Codectionary / Developer documentation / HTML

<iframe>

The <iframe> element embeds another HTML document within the current page, creating a nested browsing context. It is commonly used for embedding maps, videos from external platforms, payment widgets, or ads. Because it loads content from potentially untrusted sources, the sandbox attribute is important for restricting what an embedded page is allowed to do.

Syntax

<iframe src="https://example.com" width="600" height="400"></iframe>

Examples

Embedding a Map

A basic embedded iframe, such as a map widget.

<iframe src="https://maps.example.com/embed?q=Manchester" width="600" height="450" style="border:0;" loading="lazy"></iframe>

Sandboxed Iframe

Restricting what an embedded page is allowed to do for security.

<iframe src="https://untrusted-widget.com" sandbox="allow-scripts" width="400" height="300"></iframe>

Responsive Iframe

Making an iframe scale with its container using CSS.

<div style="position: relative; padding-bottom: 56.25%; height: 0;">
  <iframe src="https://example.com/video" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" frameborder="0"></iframe>
</div>

Attributes

  • src (URL): The URL of the page to embed
  • sandbox (string): Restricts capabilities of the embedded content, such as scripts or form submission
  • loading (lazy | eager): Controls when the iframe content loads relative to the viewport
  • allow (string): Specifies permissions policy features the iframe can use, like camera or fullscreen

Best practices

  • Always use the sandbox attribute when embedding content from a source you do not fully control
  • Use loading="lazy" for iframes below the fold to improve initial page load performance
  • Give the iframe a descriptive title attribute for screen reader users
  • Avoid iframes for content that could just as easily be a normal part of the page — they add overhead and complicate styling

Browser compatibility

Support applies to the named feature, not every attribute or behaviour in this article. Versions refer to browsers, not operating systems.

<iframe>

Desktop

Chrome
Supported
From 1
Firefox
Supported
From 1
Safari
Supported
By 4 (possibly earlier)
Edge
Supported
From 12
Opera
Supported
By 15 (possibly earlier)

Mobile

Safari on iOS
Supported
By 3.2 (possibly earlier)
Chrome for Android
Supported
From 18
Firefox for Android
Supported
From 4
Samsung Internet
Supported
From 1.0

MDN BCD record for this feature · MDN reference

Support history and limitations

Chrome

  • From 1

Firefox

  • From 1 · The resize CSS property doesn't have any effect on this element due to bug 680823.

Safari

  • By 4 (possibly earlier) · 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.

Edge

  • From 12

Opera

  • By 15 (possibly earlier)

Safari on iOS

  • By 3.2 (possibly earlier) · 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.

Chrome for Android

  • From 18

Firefox for Android

  • From 4 · The resize CSS property doesn't have any effect on this element due to bug 680823.

Samsung Internet

  • From 1.0
<iframe> src

Desktop

Chrome
Supported
From 1
Firefox
Supported
From 1
Safari
Supported
By 4 (possibly earlier)
Edge
Supported
From 12
Opera
Supported
From 15

Mobile

Safari on iOS
Supported
By 3.2 (possibly earlier)
Chrome for Android
Supported
From 18
Firefox for Android
Supported
From 4
Samsung Internet
Supported
From 1.0

MDN BCD record for this feature

Support history and limitations

Chrome

  • From 1

Firefox

  • From 1

Safari

  • By 4 (possibly earlier)

Edge

  • From 12

Opera

  • From 15

Safari on iOS

  • By 3.2 (possibly earlier)

Chrome for Android

  • From 18

Firefox for Android

  • From 4

Samsung Internet

  • From 1.0
<iframe> sandbox

Desktop

Chrome
Supported
From 5
Firefox
Supported
From 17
Safari
Supported
From 5
Edge
Supported
From 12
Opera
Supported
From 15

Mobile

Safari on iOS
Supported
From 4
Chrome for Android
Supported
From 18
Firefox for Android
Supported
From 17
Samsung Internet
Supported
From 1.0

MDN BCD record for this feature

Support history and limitations

Chrome

  • From 5

Firefox

  • From 17

Safari

  • From 5

Edge

  • From 12

Opera

  • From 15

Safari on iOS

  • From 4

Chrome for Android

  • From 18

Firefox for Android

  • From 17

Samsung Internet

  • From 1.0
<iframe> loading

Desktop

Chrome
Supported
From 77
Firefox
Supported
From 121
Safari
Supported
From 16.4
Edge
Supported
From 79
Opera
Supported
From 64

Mobile

Safari on iOS
Supported
From 16.4
Chrome for Android
Supported
From 77
Firefox for Android
Supported
From 121
Samsung Internet
Supported
From 12.0

MDN BCD record for this feature

Support history and limitations

Chrome

  • From 77

Firefox

  • From 121

Safari

  • From 16.4

Edge

  • From 79

Opera

  • From 64

Safari on iOS

  • From 16.4

Chrome for Android

  • From 77

Firefox for Android

  • From 121

Samsung Internet

  • From 12.0
<iframe> allow

Desktop

Chrome
Supported
From 60
Firefox
Supported
From 74
Safari
Supported
From 11.1
Edge
Supported
From 79
Opera
Supported
From 47

Mobile

Safari on iOS
Supported
From 11.3
Chrome for Android
Supported
From 60
Firefox for Android
Supported
From 79
Samsung Internet
Supported
From 8.0

MDN BCD record for this feature

Support history and limitations

Chrome

  • From 60

Firefox

  • From 74

Safari

  • From 11.1

Edge

  • From 79

Opera

  • From 47

Safari on iOS

  • From 11.3

Chrome for Android

  • From 60

Firefox for Android

  • From 79

Samsung Internet

  • From 8.0

MDN BCD 8.1.5 · Dataset built 2026-10-08 · Mapping reviewed 2026-10-21. These dates are not individual browser-test or claim-verification dates. Unknown means the data does not establish support.

HTML Living Standard

Specifications & further reading