HTML: iframe

The <iframe> element embeds another HTML document, such as a video, map, or trusted widget, inside the current page.

What you will learn

Minimal example

<iframe
  src="https://example.com/widget"
  title="Example status widget"
  width="600"
  height="400"
  loading="lazy">
</iframe>

The title describes the embedded content to assistive technology. Use responsive CSS so the frame works on small screens.

Restrict embedded content

<iframe
  src="/preview.html"
  title="Preview"
  sandbox="allow-scripts">
</iframe>

sandbox applies restrictions to the embedded document. Add only the permissions you understand and trust the source before embedding external content.

Common mistakes