Please note, this is a STATIC archive of website www.w3schools.com from 05 May 2020, cach3.com does not collect or store any user information, there is no "phishing" involved.
THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML <iframe> Tag


Example

An inline frame is marked up as follows:

<iframe src="https://www.w3schools.com"></iframe>
Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

The <iframe> tag specifies an inline frame.

An inline frame is used to embed another document within the current HTML document.


Browser Support

Element
<iframe> Yes Yes Yes Yes Yes

Tips and Notes

Tip: Use CSS to style the <iframe> (even to include scrollbars).


Attributes

Attribute Value Description
allow   Specifies a feature policy for the <iframe>
allowfullscreen true
false
Set to true if the <iframe> can activate fullscreen mode by calling the requestFullscreen() method
allowpaymentrequest true
false
Set to true if a cross-origin <iframe> should be allowed to invoke the Payment Request API
height pixels Specifies the height of an <iframe>. Default height is 150 pixels
name text Specifies the name of an <iframe>
referrerpolicy no-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
same-origin
strict-origin
strict-origin-when-cross-origin
unsafe-url
Specifies how much/which referrer information that will be sent when processing the iframe attributes
sandbox allow-forms
allow-pointer-lock
allow-popups
allow-same-origin
allow-scripts
allow-top-navigation
Enables an extra set of restrictions for the content in an <iframe>
src URL Specifies the address of the document to embed in the <iframe>
srcdoc HTML_code Specifies the HTML content of the page to show in the <iframe>
width pixels Specifies the width of an <iframe>. Default width is 300 pixels


Global Attributes

The <iframe> tag also supports the Global Attributes in HTML.


Event Attributes

The <iframe> tag also supports the Event Attributes in HTML.


More Examples

Example

Float an iframe to the right (with CSS):

<iframe src="/default.asp" width="200" height="200" style="float:right"></iframe>
Try it Yourself »

Example

Add iframe borders (with CSS):

<iframe src="/default.asp" width="200" height="200" style="border:1px solid lightgrey;"></iframe>
Try it Yourself »

Related Pages

HTML tutorial: HTML Iframes

HTML DOM reference: IFrame Object


Default CSS Settings

Most browsers will display the <iframe> element with the following default values:

iframe:focus {
  outline: none;
}

iframe[seamless] {
  display: block;
}