Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Embedding External Content – iframe, em | HTML Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. HTML Course

Lesson 11 of 55

·HTML

Embedding External Content – iframe, embed, object

8 min

Course progress20%

What you'll learn

Keep these ideas in mind as you work through the lesson.

5 points
  • When to use `<iframe>`, `<embed>`, `<object>` for external content
  • Security considerations (`sandbox` on iframes, HTTPS, `allow` attribute)
  • Providing descriptive `title` or `aria-label` for accessibility
  • Lazy loading iframes with `loading='lazy'` for performance
  • Fallback strategies for unsupported browsers

Embedding Other Pages

<iframe src='https://example.com' title='Example site' width='600' height='400' loading='lazy' sandbox='allow-scripts allow-same-origin'></iframe>

<embed src='document.pdf' type='application/pdf' width='100%' height='500' />

<object data='diagram.svg' type='image/svg+xml' width='300' height='200'></object>

When to use each element

  • <iframe> – Embed another HTML page; ideal for third‑party widgets, maps, or videos. Use the sandbox attribute to restrict capabilities (e.g., allow-scripts).
  • <embed> – Generic external resource (PDF, legacy Flash). Prefer <object> for better fallback handling and for SVG.
  • <object> – Can embed SVG, PDFs, or other resources and provide fallback content inside the tag.

Security considerations

  • Always provide a descriptive title or aria-label on <iframe> for screen readers.
  • Use sandbox to isolate the embedded page and prevent it from running unwanted scripts or accessing the parent’s DOM.
  • Add allow attribute for specific features (e.g., allow='camera; microphone') only when required.
  • Serve the embedded resource over HTTPS to avoid mixed‑content warnings.

Quick checklist for embeds

  1. <iframe> has a clear title? ✅
  2. sandbox attribute applied where appropriate? ✅
  3. Fallback content inside <object> for unsupported browsers? ✅
  4. Resources loaded over HTTPS? ✅
  5. loading='lazy' applied to large iframes? ✅

Tip: Combine loading='lazy' with sandbox for off‑screen iframes to improve performance and security.

Make it stickPractice what you've learned1 quiz · 2 practical tests · Optional activities from HTML CourseBrowse activities
Previous lessonMultimedia – Audio and VideoContinue to lesson 12Setting Up Your Development EnvironmentBack to HTML Course curriculum