Skip to content

06. iframe Element

The <iframe> (inline frame) element embeds another HTML page within the current page. It’s commonly used for embedding videos, maps, social media content, and other external resources. Understanding iframe usage, security considerations, and best practices is important for safe and effective content embedding.

<iframe src="https://example.com/page.html"></iframe>

Source URL:

<iframe src="https://example.com"></iframe>

Dimensions:

<iframe src="https://example.com" width="800" height="600"></iframe>

Accessibility title:

<iframe src="https://example.com" title="Embedded content"></iframe>

Restrict iframe capabilities:

<iframe src="https://example.com" sandbox="allow-scripts"></iframe>

Feature policy:

<iframe
src="https://example.com"
allow="camera; microphone">
</iframe>
<iframe
src="https://www.youtube.com/embed/VIDEO_ID"
width="560"
height="315"
title="YouTube video">
</iframe>
<iframe
src="https://www.google.com/maps/embed?pb=..."
width="600"
height="450"
title="Google Maps">
</iframe>
<iframe src="https://example.com" title="Embedded content"></iframe>
<iframe
src="https://untrusted.com"
sandbox="allow-scripts"
title="Untrusted content">
</iframe>