Media & Embedded Content

HTML <iframe> Tag

The <iframe> tag specifies an inline frame.

Definition and Usage

The <iframe> tag specifies an inline frame.

Standard Syntax:<iframe>...</iframe>

Interactive ExampleRunnable

HTML <iframe> Example

html
Try it Yourself
Live code demonstration for the <iframe> tag. Click "Try it Yourself" to edit and experiment in real time.
<div style="font-family: system-ui, sans-serif; padding: 16px; background: #ffffff; border-radius: 8px; border: 1px solid #e2e8f0; color: #0f172a;">
<iframe src="https://ea-academy.com" title="EA Academy Free 
    Online Web Tutorials"></iframe>
</div>

Attributes for <iframe>

10 Supported Attributes
AttributeValuesDefaultDescription
allowstringnoneSpecifies a feature policy for the <iframe>
allowfullscreentruefalsenoneSet to true if the <iframe> can activate fullscreen mode by calling the requestFullscreen() method
heightpixelsnoneSpecifies the height of an <iframe>. Default height is 150 pixels
loadingeagerlazynoneSpecifies whether a browser should load an iframe immediately or to defer loading of iframes until some conditions are met
nametextnoneSpecifies the name of an <iframe>
referrerpolicyno-referrerno-referrer-when-downgradeorigin origin-when-cross-originsame-originstrict-origin-when-cross-originunsafe-urlnoneSpecifies which referrer information to send when fetching the iframe
sandboxallow-formsallow-pointer-lockallow-popups allow-same-origin allow-scripts allow-top-navigationnoneEnables an extra set of restrictions for the content in an <iframe>
srcURLnoneSpecifies the address of the document to embed in the <iframe>
srcdocHTML_codenoneSpecifies the HTML content of the page to show in the <iframe>
widthpixelsnoneSpecifies the width of an <iframe>. Default width is 300 pixels
Global Attributes

The <iframe> tag also supports the standard global attributes in HTML, including class, id, style, title, hidden, and data-*.

HTML Global Attributes Reference →
Event Attributes

The <iframe> tag supports event attributes in HTML, such as onclick, onmouseover, onfocus, and more.

HTML Event Attributes Reference →

Browser Compatibility

ChromeEdgeFirefoxSafariOpera

More Tags in Media & Embedded Content

View All 123Tags →