SA-21/06, C-11, Asapur, Varanasi, UP support@kamaldnp.com +91 8318013442
HTML
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
Final Test — Certificate ₹10
Try this code live
Lesson 23 of 35

HTML Iframes: Embed YouTube, Maps & Pages in HTML

4 min read · Free · No login needed

An iframe (inline frame) shows another web page inside your page, in a small window. It is how YouTube videos, Google Maps, and other embedded content appear on websites.

Diagram — see how it fits together
Infographic: a page inside a page with iframe

The tag is <iframe src="https://www.youtube.com/embed/VIDEO_ID" width="560" height="315"></iframe>. The src is the page to show; width and height set the size of the window.

Common uses

  • YouTube videos — click Share → Embed on any video and copy the iframe code.
  • Google Maps — Share → Embed a map, and visitors can pan and zoom without leaving your page.
  • Other pages — showing a form, a document, or a page from another site.

Things to watch out for

An iframe loads a whole second page, so it slows your page down — use it only when you need it. Some websites refuse to be shown inside an iframe (they send a header that blocks it). And for security, an iframe can run scripts from the other site, so only embed content from sources you trust. You can limit what an embedded page may do with the sandbox attribute.

Tip: Give every iframe a title attribute (for example, title="YouTube video player"). Screen readers announce it, so blind visitors know what the frame contains.

What an iframe is

An <iframe> is a window inside your page that shows another web page. The other page loads inside a rectangle on your page, and it works as if the visitor had opened it in its own tab. It is how YouTube videos, Google Maps, and payment pages are placed inside other websites.

Iframe attributes

AttributeValueDescription
srca web addressThe page to show inside the frame. Required.
width / heightpixels or %The size of the frame on your page.
titletextDescribes the frame for screen readers. Always add it.
loadinglazyLoads the frame only when the user scrolls near it.
allowfullscreen—Lets the framed page go full screen (needed for videos).
sandbox—Blocks scripts, forms, and popups inside the frame — extra safety.

A YouTube video embedded the usual way looks like this:

<iframe width="560" height="315"
  src="https://www.youtube.com/embed/VIDEO_ID"
  title="YouTube video player"
  allowfullscreen></iframe>
Note: Not every site allows itself to be framed. Many sites send a header that says "do not show me inside an iframe", and the browser then shows a blank box. If your iframe is empty, the other site is probably blocking it — there is nothing wrong with your code.
Tip: Add loading="lazy" to iframes below the fold. A map or video the visitor has not scrolled to should not slow down the first paint of your page.

Common mistakes

  • Forgetting the title attribute — screen reader users then hear only "frame" with no idea what is inside.
  • Embedding a site you do not trust without sandbox — the framed page can run scripts in your visitor's browser.
  • Setting a tiny fixed height — the framed page gets a scrollbar inside a scrollbar, which is horrible to use.
  • Using an iframe to show your own pages — a link or a server-side include is almost always the better choice.

Example explained

  • <!DOCTYPE html> — tells the browser this is an HTML5 page, so it renders in standard mode.
  • <h1>Watch Our Intro</h1> — the heading above the video, so visitors know what they are about to watch.
  • <iframe ...> — the window that shows the YouTube page inside this page. The src is the video's embed address, and width="560" and height="315" set the size of the window.
  • title="YouTube video player" — describes the frame for screen readers, so blind visitors know what is inside it.
  • allowfullscreen — lets the visitor expand the video to fill the whole screen.

Example

Example
<!DOCTYPE html>
<html>
<head>
<title>Iframes</title>
</head>
<body>

<h1>Watch Our Intro</h1>
<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" title="YouTube video player" frameborder="0" allowfullscreen></iframe>

</body>
</html>

Output

Output — how it looks in the browser
Output of HTML Iframes: Embed YouTube, Maps & Pages in HTML

Try it yourself — live editor

Change the code below and press Run to see the result instantly. No file to save, no login needed.

Result

Frequently asked questions

The questions learners ask most about this lesson — read the question, then open it to see the answer.

1. What is an iframe?

It is a window inside your page that shows another web page, used for YouTube videos, Google Maps, and other embedded content.

2. Why might an iframe show a blank box?

Some websites send a header that blocks framing, so the browser shows a blank box; there is nothing wrong with your code.

3. What should you always add to an iframe?

A title attribute, so screen readers can announce what the frame contains.

Why learn this yourself — and not just ask AI?

AI can write code for you, but it cannot think for you. When you learn HTML yourself, your brain builds the real skill: you understand why a page looks the way it does, you can fix it when it breaks, and you can answer it in an exam or an interview without help. That is the skill that gets you a job — not a copied answer.

Get certified — just ₹10

Finish all 35 lessons, pass the test (80%), pay ₹10 and get your certificate.

Take the test

Prefer watching? Video courses teach the same topics step by step.

Go further with a full course

Free tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.

Ethical Hacking & Cyber Security Workshop
View
Summer Training in Python Programming 2026
₹3,000
View
Android & iOS App Development using Flutter 2026
₹5,000
View
Browse all courses
HTML — Lessons
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
Final Test — Certificate ₹10

🤖 KAMALDNP AI Assistant

Ask about courses, website & more

Hi! I'm KAMALDNP AI Assistant. Ask me about our courses, website features, or anything else! 😊
Please wait 5s...
🤖 KAMALDNP Assistant ✕

Request human callback:

🔐 Login Required
✕

Please log in to download. You will stay on this page after logging in!

New here? Register now →