HTML Embed and Object: External Resources
Embed an external resource
embed is a void element for external content. src specifies its resource, type gives a MIME hint, and dimensions define its display area. Browser support for particular resource types varies. For ordinary images, prefer img with suitable alt. These examples use the original files in media-fixtures/; open the supplied preview from a local static server or place the files at the shown paths.
<embed src="media-fixtures/diagram.svg" type="image/svg+xml" width="160" height="90"><p>Diagram: green circle on a pale background.</p>The browser may render the SVG; a text description remains available.
Use object with fallback
object represents an external resource specified using data, not src. Its children can supply fallback content if the resource cannot be represented. Use a meaningful text alternative rather than an empty object.
<object data="media-fixtures/diagram.svg" type="image/svg+xml" width="160" height="90"> <p>Diagram: green circle on a pale background.</p></object>The SVG may render; the child paragraph is fallback for unavailable representation.
Prefer a specialized element
An img is simpler for an image; video for video and iframe for a nested page. Both object and embed can involve resource-specific rendering and security restrictions. CSP object-src can block both. Do not depend on old plug-ins.
<img src="media-fixtures/diagram.svg" width="160" height="90" alt="Green circle on a pale background">A native image provides a straightforward text alternative.
Common mistakes and practice
Do not put child fallback inside embed, which is void. A PDF viewer or other resource handler may not be available; offer a normal link and use trusted resources.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Embed and Object: External Resources — Knowledge Check
Apply the media or embedding concepts from this lesson.
Which attribute specifies the object resource?
Which element is void and cannot contain child fallback?
Which is usually best for an ordinary SVG image with text alternative?
Which object content can provide a fallback when the resource cannot be used?
Which element typically embeds an external resource without child content?