SyntaxStudy
Sign Up
HTML Beginner 1 min read

HTML iframes

HTML iframes

An <iframe> (inline frame) embeds another HTML document inside your page. It's used for maps, YouTube videos, and third-party widgets.

Key Attributes

  • src — URL of the document to embed
  • width / height — Frame size
  • title — Accessible description (required)
  • allowfullscreen — Enables fullscreen for videos
  • loading="lazy" — Defer loading

Security

The sandbox attribute restricts what the embedded page can do (no scripts, no popups, etc.).

Example
<!-- Embed a YouTube video -->
<iframe
  width="560"
  height="315"
  src="https://www.youtube.com/embed/dQw4w9WgXcQ"
  title="YouTube video"
  allowfullscreen>
</iframe>

<!-- Google Maps -->
<iframe
  src="https://maps.google.com/maps?q=London&output=embed"
  width="600"
  height="400"
  title="London Map">
</iframe>

<!-- Sandboxed iframe -->
<iframe src="page.html" sandbox="allow-scripts" title="Safe embed"></iframe>