Each embedded browsing context has its own document and allows URL navigations. The navigations of each embedded browsing context are linearized into the session history of the topmost browsing context. The browsing context that embeds the others is called the parent browsing context. The topmost browsing context — the one with no parent — is usually the browser window, represented by the
Warning: Because each browsing context is a complete document environment, every
<iframe> in a page requires increased memory and other computing resources. While theoretically you can use as many
<iframe>s as you like, check for performance problems.
This element includes the global attributes.
Specifies a Permissions Policy for the
<iframe>. The policy defines what features are available to the
<iframe>(for example, access to the microphone, camera, battery, web-share, etc.) based on the origin of the request.
See iframes in the
Permissions-Policytopic for examples.
Note: A Permissions Policy specified by the
allowattribute implements a further restriction on top of the policy specified in the
Permissions-Policyheader. It doesn't replace it.
<iframe>can activate fullscreen mode by calling the
Note: This attribute is considered a legacy attribute and redefined as
trueif a cross-origin
<iframe>should be allowed to invoke the Payment Request API.
Note: This attribute is considered a legacy attribute and redefined as
trueto make the
<iframe>credentialless, meaning that its content will be loaded in a new, ephemeral context. It doesn't have access to the network, cookies, and storage data associated with its origin. It uses a new context local to the top-level document lifetime. In return, the
Cross-Origin-Embedder-Policy(COEP) embedding rules can be lifted, so documents with COEP set can embed third-party documents that do not. See IFrame credentialless for more details.
The height of the frame in CSS pixels. Default is
Indicates when the browser should load the iframe:
Load the iframe immediately on page load (this is the default value).
Defer loading of the iframe until it reaches a calculated distance from the visual viewport, as defined by the browser. The intent is to avoid using the network and storage bandwidth required to fetch the frame until the browser is reasonably certain that it will be needed. This improves the performance and cost in most typical use cases, in particular by reducing initial page load times.
A targetable name for the embedded browsing context. This can be used in the
targetattribute of the
formtargetattribute of the
<button>elements; or the
windowNameparameter in the
Indicates which referrer to send when fetching the frame's resource:
Refererheader will not be sent.
The referrer sent to other origins will be limited to the scheme, the host, and the port. Navigations on the same origin will still include the path.
A referrer will be sent for same origin, but cross-origin requests will contain no referrer information.
Only send the origin of the document as the referrer when the protocol security level stays the same (HTTPS→HTTPS), but don't send it to a less secure destination (HTTPS→HTTP).
Send a full URL when performing a same-origin request, only send the origin when the protocol security level stays the same (HTTPS→HTTPS), and send no header to a less secure destination (HTTPS→HTTP).
The referrer will include the origin and the path (but not the fragment, password, or username). This value is unsafe, because it leaks origins and paths from TLS-protected resources to insecure origins.
Controls the restrictions applied to the content embedded in the
<iframe>. The value of the attribute can either be empty to apply all restrictions, or space-separated tokens to lift particular restrictions:
Allows downloading files through an
<area>element with the download attribute, as well as through the navigation that leads to a download of a file. This works regardless of whether the user clicked on the link, or JS code initiated it without user interaction.
Allows for downloads to occur without a gesture from the user.
Allows the page to submit forms. If this keyword is not used, form will be displayed as normal, but submitting it will not trigger input validation, sending data to a web server or closing a dialog.
Allows the page to open modal windows by
Window.prompt(), while opening a
<dialog>is allowed regardless of this keyword. It also allows the page to receive
Lets the resource lock the screen orientation.
Allows the page to use the Pointer Lock API.
Allows a sandboxed document to open a new browsing context without forcing the sandboxing flags upon it. This will allow, for example, a third-party advertisement to be safely sandboxed without forcing the same restrictions upon the page the ad links to. If this flag is not included, a redirected page, popup window, or new tab will be subject to the same sandbox restrictions as the originating
Allows embedders to have control over whether an iframe can start a presentation session.
Allows the page to run scripts (but not create pop-up windows). If this keyword is not used, this operation is not allowed.
Allows a document loaded in the
<iframe>to use the Storage Access API to request access to unpartitioned cookies.
Lets the resource navigate the top-level browsing context (the one named
Lets the resource navigate the top-level browsing context, but only if initiated by a user gesture.
Allows navigations to non-
httpprotocols built into browser or registered by a website. This feature is also activated by
- When the embedded document has the same origin as the embedding page, it is strongly discouraged to use both
allow-same-origin, as that lets the embedded document remove the
sandboxattribute — making it no more secure than not using the
sandboxattribute at all.
- Sandboxing is useless if the attacker can display content outside a sandboxed
iframe— such as if the viewer opens the frame in a new tab. Such content should be also served from a separate origin to limit potential damage.
Note: When redirecting the user, opening a popup window, or opening a new tab from an embedded page within an
sandboxattribute, the new browsing context is subject to the same
sandboxrestrictions. This can create issues — for example, if a page embedded within an
sandbox="allow-popups-to-escape-sandbox"attribute set on it opens a new site in a separate tab, form submission in that new browsing context will silently fail.
The URL of the page to embed. Use a value of
about:blankto embed an empty page that conforms to the same-origin policy. Also note that programmatically removing an
<iframe>'s src attribute (e.g. via
about:blankto be loaded in the frame in Firefox (from version 65), Chromium-based browsers, and Safari/iOS.
Inline HTML to embed, overriding the
srcattribute. If a browser does not support the
srcdocattribute, it will fall back to the URL in the
The width of the frame in CSS pixels. Default is
These attributes are deprecated and may no longer be supported by all user agents. You should not use them in new content, and try to remove them from existing content.
The alignment of this element with respect to the surrounding context.
1(the default) draws a border around this frame. The value
0removes the border around this frame, but you should instead use the CSS property
A URL of a long description of the frame's content. Due to widespread misuse, this is not helpful for non-visual browsers.
The amount of space in pixels between the frame's content and its top and bottom borders.
The amount of space in pixels between the frame's content and its left and right borders.
Indicates when the browser should provide a scrollbar for the frame:
With the DOM
HTMLIFrameElement object, scripts can access the
window object of the framed resource via the
contentWindow property. The
contentDocument property refers to the
document inside the
<iframe>, same as
From the inside of a frame, a script can get a reference to its parent window with
Script access to a frame's content is subject to the same-origin policy. Scripts cannot access most properties in other
window objects if the script was loaded from a different origin, including scripts inside a frame accessing the frame's parent. Cross-origin communication can be achieved using
This example embeds the page at https://example.org in an iframe.
title="iframe Example 1"
People navigating with assistive technology such as a screen reader can use the
title attribute on an
<iframe> to label its content. The title's value should concisely describe the embedded content:
title="Wikipedia page for Avocados"
Without this title, they have to navigate into the
<iframe> to determine what its embedded content is. This context shift can be confusing and time-consuming, especially for pages with multiple
<iframe>s and/or if embeds contain interactive content like video or audio.
|Flow content, phrasing content, embedded content, interactive content, palpable content.
|None, both the starting and ending tag are mandatory.
|Any element that accepts embedded content.
|Implicit ARIA role
|No corresponding role
|Permitted ARIA roles
BCD tables only load in the browser