HTML Basics
HTML Iframes
An iframe embeds another web page inside your current page. It is commonly used for YouTube videos, maps, and third-party widgets.
What is an Iframe?
The word iframe means 'inline frame'. The <iframe> element loads a separate HTML document inside a rectangular region of your page.
<iframe src="https://example.com"
width="600" height="400"
title="Embedded page">
</iframe>Embedding a YouTube Video
YouTube gives you an iframe embed code. You simply paste it into your page.
<iframe width="560" height="315"
src="https://www.youtube.com/embed/VIDEO_ID"
title="YouTube video"
allowfullscreen>
</iframe>Useful Attributes
| Attribute | Purpose |
|---|---|
| src | The URL of the page to embed |
| width / height | Size of the frame in pixels |
| title | Accessible description of the frame |
| allowfullscreen | Lets embedded videos go fullscreen |
| sandbox | Restricts what the embedded page can do |
⚠️
Only embed pages you trust. Many sites block being framed for security. Use the sandbox attribute to limit what an embedded page is allowed to do.
