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.

A basic iframe
<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.

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

Useful Attributes

AttributePurpose
srcThe URL of the page to embed
width / heightSize of the frame in pixels
titleAccessible description of the frame
allowfullscreenLets embedded videos go fullscreen
sandboxRestricts 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.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships