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

PDF Document

Legacy Plugin Content

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.

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 alt attribute 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

Related

  • <object> - Similar embedding with fallback content support
  • <iframe> - For embedding HTML documents with security sandboxing
  • <video> - For video with native controls, captions, and multiple sources
  • <audio> - For audio with native controls and multiple sources