embed
The embed element is a void element for embedding external content. It provides no fallback mechanism -- prefer modern alternatives like iframe, video, and audio.
Description
The <embed> element provides an integration point for external content or applications, typically handled by browser plugins. It is a void element (self-closing) with no closing tag and no fallback content mechanism.
Originally designed for plugin content like Flash and Java applets, <embed> has limited utility in modern web development. Unlike <object>, it cannot contain fallback markup, so if the resource fails to load the user sees nothing.
When to Use
In modern HTML, there is almost always a better alternative. The <embed> element should only be used when no other element supports the content type and you are certain the resource will load.
Prefer Modern Alternatives
- Use
<iframe>for embedding HTML documents and web applications - Use
<video>for video content with native controls and captions - Use
<audio>for audio content with native controls - Use
<img>for images including external SVG files - Use
<svg>for inline vector graphics - Use
<object>if you need fallback content for a non-HTML resource
Examples
SVG File
<embed src="diagram.svg" type="image/svg+xml" width="600" height="400">
PDF Document
<embed src="document.pdf" type="application/pdf" width="100%" height="600">
Legacy Plugin Content
<embed src="animation.swf" type="application/x-shockwave-flash" width="400" height="300">
Plugin-based content (Flash, Java, Silverlight) is no longer supported by modern browsers. This syntax is shown for historical reference only.
embed vs. object
The key difference is fallback content. <embed> is a void element with no closing tag, so it cannot contain alternative markup. <object> supports content between its tags that is displayed when the resource fails to load.
<!-- embed: no fallback if the resource fails --><embed src="chart.svg" type="image/svg+xml" width="400" height="300"> <!-- object: fallback content is displayed on failure --><object data="chart.svg" type="image/svg+xml" width="400" height="300"> <p>Chart unavailable. <a href="chart.png">View as image</a>.</p></object> <!-- Best: use native elements --><img src="chart.svg" alt="Quarterly revenue chart" width="400" height="300">
For any use case where the resource might not load, prefer <object> or a native element over <embed>.
Attributes
| Attribute | Description |
|---|---|
src |
URL of the resource to embed. |
type |
MIME type of the embedded content (e.g., image/svg+xml, application/pdf). |
width |
Display width of the embedded content in pixels. |
height |
Display height of the embedded content in pixels. |
This element also supports global attributes.
Accessibility
The <embed> element has significant accessibility limitations:
- No fallback content mechanism -- if the resource cannot be loaded, the user gets nothing
- No native
altattribute like<img> - Embedded content is opaque to screen readers unless the content itself is accessible
- Prefer elements with built-in accessibility semantics (
<img>,<video>,<audio>) whenever possible