Lesson 11 of 55
HTMLEmbedding External Content – iframe, embed, object
8 min
Course progress20%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 11 of 55
HTML8 min
Keep these ideas in mind as you work through the lesson.
<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>
<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.title or aria-label on <iframe> for screen readers.sandbox to isolate the embedded page and prevent it from running unwanted scripts or accessing the parent’s DOM.allow attribute for specific features (e.g., allow='camera; microphone') only when required.<iframe> has a clear title? ✅sandbox attribute applied where appropriate? ✅<object> for unsupported browsers? ✅loading='lazy' applied to large iframes? ✅Tip: Combine
loading='lazy'withsandboxfor off‑screen iframes to improve performance and security.