There was a scripting error on this page. While it is being addressed by site editors, you can view partial content below.

Our volunteers haven't translated this article into עברית yet. Join us and help get the job done!
You can also read the article in English (US).


The HTML Inline Frame element (<iframe>) represents a nested {{Glossary("browsing context")}}, embedding another HTML page into the current one.

{{EmbedInteractiveExample("pages/tabbed/iframe.html", "tabbed-standard")}}

Each embedded browsing context has its own session history and document. 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 {{domxref("Window")}} object.

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.

Content categories Flow content, phrasing content, embedded content, interactive content, palpable content.
Permitted content Fallback content, i.e. content that is normally not rendered, but that browsers not supporting the <iframe> element will render. (RSS readers and email clients often show the fallback content instead.)
Tag omission {{no_tag_omission}}
Permitted parents Any element that accepts embedded content.
Permitted ARIA roles {{ARIARole("application")}}, {{ARIARole("document")}}, {{ARIARole("img")}}
DOM interface {{domxref("HTMLIFrameElement")}}


This element includes the global attributes.

Specifies a feature policy for the <iframe>.
Set to true if the <iframe> can activate fullscreen mode by calling the {{domxref("Element.requestFullscreen", "requestFullscreen()")}} method.
This attribute is considered a legacy attribute and redefined as allow="fullscreen".
Set to true if a cross-origin <iframe> should be allowed to invoke the Payment Request API.
This attribute is considered a legacy attribute and redefined as allow="payment".
{{htmlattrdef("csp")}} {{experimental_inline}}
A Content Security Policy enforced for the embedded resource. See {{domxref("HTMLIFrameElement.csp")}} for details.
The height of the frame in CSS pixels. Default is 150.
{{htmlattrdef("importance")}} {{experimental_inline}}
The download priority of the resource in the <iframe>'s src attribute. Allowed values:
auto (default)
No preference. The browser uses its own heuristics to decide the priority of the resource.
The resource should be downloaded before other lower-priority page resources.
The resource should be downloaded after other higher-priority page resources.
A targetable name for the embedded browsing context. This can be used in the target attribute of the {{HTMLElement("a")}}, {{HTMLElement("form")}}, or {{HTMLElement("base")}} elements; the formtarget attribute of the {{HTMLElement("input")}} or {{HTMLElement("button")}} elements; or the windowName parameter in the {{domxref("","")}} method.
Indicates which referrer to send when fetching the frame's resource:
  • no-referrer: The {{HTTPHeader("Referer")}} header will not be sent.
  • no-referrer-when-downgrade (default): The {{HTTPHeader("Referer")}} header will not be sent to {{Glossary("origin")}}s without {{Glossary("TLS")}} ({{Glossary("HTTPS")}}).
  • origin: The sent referrer will be limited to the origin of the referring page: its scheme, {{Glossary("host")}}, and {{Glossary("port")}}.
  • origin-when-cross-origin: 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.
  • same-origin: A referrer will be sent for {{Glossary("Same-origin policy", "same origin")}}, but cross-origin requests will contain no referrer information.
  • strict-origin: 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).
  • strict-origin-when-cross-origin: 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).
  • unsafe-url: 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.
Applies extra restrictions to the content in the frame. The value of the attribute can either be empty to apply all restrictions, or space-separated tokens to lift particular restrictions:
  • allow-downloads-without-user-activation {{experimental_inline}}: Allows for downloads to occur without a gesture from the user.
  • allow-forms: Allows the resource to submit forms. If this keyword is not used, form submission is blocked.
  • allow-modals: Lets the resource open modal windows.
  • allow-orientation-lock: Lets the resource lock the screen orientation.
  • allow-pointer-lock: Lets the resource use the Pointer Lock API.
  • allow-popups: Allows popups (such as, target="_blank", or showModalDialog()). If this keyword is not used, the popup will silently fail to open.
  • allow-popups-to-escape-sandbox: Lets the sandboxed document open new windows without those windows inheriting the sandboxing. For example, this can safely sandbox an advertisement without forcing the same restrictions upon the page the ad links to.
  • allow-presentation: Lets the resource start a presentation session.
  • allow-same-origin: If this token is not used, the resource is treated as being from a special origin that always fails the {{Glossary("same-origin policy")}}.
  • allow-scripts: Lets the resource run scripts (but not create popup windows).
  • allow-storage-access-by-user-activation {{experimental_inline}}: Lets the resource request access to the parent's storage capabilities with the Storage Access API.
  • allow-top-navigation: Lets the resource navigate the top-level browsing context (the one named _top).
  • allow-top-navigation-by-user-activation: Lets the resource navigate the top-level browsing context, but only if initiated by a user gesture.
Notes about sandboxing:
  • When the embedded document has the same origin as the embedding page, it is strongly discouraged to use both allow-scripts and allow-same-origin, as that lets the embedded document remove the sandbox attribute — making it no more secure than not using the sandbox attribute 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.
  • The sandbox attribute is unsupported in Internet Explorer 9 and earlier.
The URL of the page to embed. Use a value of about:blank to embed an empty page that conforms to the same-origin policy. Also note that programatically removing an <iframe>'s src attribute (e.g. via {{domxref("Element.removeAttribute()")}}) causes about:blank to be loaded in the frame in Firefox (from version 65), Chromium-based browsers, and Safari/iOS.
Inline HTML to embed, overriding the src attribute. If a browser does not support the srcdoc attribute, it will fall back to the URL in the src attribute.
The width of the frame in CSS pixels. Default is 300.

Deprecated attributes

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.

{{htmlattrdef("align")}} {{deprecated_inline("html4.01")}}, {{obsolete_inline("html5")}}
The alignment of this element with respect to the surrounding context.
{{htmlattrdef("frameborder")}} {{obsolete_inline("html5")}}
The value 1 (the default) draws a border around this frame. The value 0 removes the border around this frame, but you should instead use the CSS property {{cssxref("border")}} to control <iframe> borders.
{{htmlattrdef("longdesc")}} {{obsolete_inline("html5")}}
A URL of a long description of the frame's content. Due to widespread misuse, this is not helpful for non-visual browsers.
{{htmlattrdef("marginheight")}} {{obsolete_inline("html5")}}
The amount of space in pixels between the frame's content and its top and bottom borders.
{{htmlattrdef("marginwidth")}} {{obsolete_inline("html5")}}
The amount of space in pixels between the frame's content and its left and right borders.
{{htmlattrdef("scrolling")}} {{obsolete_inline("html5")}}
Indicates when the browser should provide a scrollbar for the frame:
  • auto: Only when the frame's content is larger than its dimensions.
  • yes: Always show a scrollbar.
  • no: Never show a scrollbar.

Non-standard attributes {{non-standard_inline}}

{{htmlattrdef("mozbrowser")}} {{non-standard_inline}}
See {{bug(1318532)}} for exposing this to WebExtensions in Firefox.
Makes the <iframe> act like a top-level browser window. See Browser API for details.
Available only to WebExtensions.


Inline frames, like {{HTMLElement("frame")}} elements, are included in the {{domxref("window.frames")}} pseudo-array.

With the DOM {{domxref("HTMLIFrameElement")}} object, scripts can access the {{domxref("window")}} object of the framed resource via the {{domxref("HTMLIFrameElement.contentWindow", "contentWindow")}} property. The {{domxref("HTMLIFrameElement.contentDocument", "contentDocument")}} property refers to the document inside the <iframe>, same as contentWindow.document.

From the inside of a frame, a script can get a reference to its parent window with {{domxref("window.parent")}}.

Script access to a frame's content is subject to the {{Glossary("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 {{domxref("Window.postMessage()")}}.

Positioning and scaling

As a replaced element, the position, alignment, and scaling of the embedded document within the <iframe> element's box, can be adjusted with the {{cssxref("object-position")}} and {{cssxref("object-fit")}} properties.


A simple <iframe>

An <iframe> in action. After creating the frame, when the user clicks a button, its title is displayed in an alert.


<iframe src="" title="iframe Example 1" width="400" height="300"></iframe>


{{ EmbedLiveSample('Example1', 640,400)}}

Open a link in an <iframe> in another tab

In this example, a Google map is displayed in a frame;


<iframe id="Example2"
    title="iframe Example 2"
    width="400" height="300"


{{ EmbedLiveSample('Example2', 640, 400)}}

Accessibility concerns

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:

<iframe title="Wikipedia page for Avocados" src=""></iframe>

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.


Specification Status Comment
{{SpecName('Referrer Policy', '#referrer-policy-delivery-referrer-attribute', 'referrerpolicy attribute')}} {{Spec2('Referrer Policy')}} Added the referrerpolicy attribute.
{{SpecName('HTML WHATWG', 'iframe-embed-object.html#the-iframe-element', '<iframe>')}} {{Spec2('HTML WHATWG')}}
{{SpecName('HTML5 W3C', 'embedded-content-0.html#the-iframe-element', '<iframe>')}} {{Spec2('HTML5 W3C')}}
{{SpecName('HTML4.01', 'present/frames.html#h-16.5', '<iframe>')}} {{Spec2('HTML4.01')}}
{{SpecName('Screen Orientation')}} {{Spec2('Screen Orientation')}} Adds allow-orientation-lock to the sandbox attribute.
{{SpecName('Presentation','#sandboxing-and-the-allow-presentation-keyword','allow-presentation')}} {{Spec2('Presentation')}} Adds allow-presentation to the sandbox attribute

Browser compatibility

{{Compat("html.elements.iframe", 3)}}