HTML <embed> Tag
The <embed> tag is used to embed the content, which is not understood by the browser. Description, attributes and examples.
The HTML <embed> tag embeds external content at the point where it appears in the document. Originally it was a container for browser plug-ins (Flash, Java applets, QuickTime, RealPlayer), which were separate programs the browser handed the content off to.
This page covers what <embed> is used for today, a working PDF example, how it compares to <object>, <iframe>, <video>, and <audio>, plus the attributes and accessibility notes you need.
Why plug-ins are dead (and what <embed> is for now)
Browser plug-ins were retired industry-wide: NPAPI plug-ins (Java, Silverlight) were removed from Chrome and Firefox, and Adobe Flash reached end-of-life on December 31, 2020. They were a security and stability liability, and every plug-in capability now has a native HTML replacement.
So <embed> is rarely the right choice in new code. The one place you still see it is embedding a PDF using the browser's built-in PDF viewer, which most modern browsers expose as a content handler rather than a plug-in. For everything else, reach for a dedicated element:
| You want to embed… | Use this instead |
|---|---|
| A video file | <video> |
| An audio file | <audio> |
| Another web page / external site | <iframe> |
| Any resource with a fallback | <object> |
<embed> vs <object> vs <iframe>
All three insert external content, but they differ in flexibility and fallback support:
| Feature | <embed> | <object> | <iframe> |
|---|---|---|---|
| Closing tag | No (empty element) | Yes | Yes |
| Fallback content | No — nothing renders if the type fails | Yes — content between the tags shows on failure | Yes — content between the tags shows if iframes are disabled |
| Parameters | Via attributes only | Via child <param> elements | Via src URL / attributes |
| Best for today | Built-in PDF viewer | Resource needing a graceful fallback | Embedding HTML pages |
In HTML5, <embed> is a standard element, so documents using it validate correctly. For broader compatibility you can place an <embed> inside an <object> so the <embed> acts as the fallback.
Use the CSS object-position property to correct the positioning of the embedded object within the element’s frame.
Syntax
The <embed> tag is empty, which means that the closing tag isn’t required. But in XHTML, the <embed> tag must be closed (<embed/>).
Example of the HTML <embed> tag for placing a logo:
Example of the HTML <embed> Tag
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<embed src="/uploads/media/default/0001/01/0710cad7a1017902166203def268a0df2a5fd545.png" />
</body>
</html>Example of the HTML <embed> tag for embedding a PDF:
This is the most common modern use of <embed>. The browser renders the PDF with its built-in viewer. Always set the type to application/pdf so the browser knows how to handle the file, and give the embed dimensions so it reserves space on the page.
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<embed
type="application/pdf"
src="/files/sample.pdf"
width="600"
height="800"
title="Sample PDF document" />
</body>
</html>Example of the HTML <embed> tag for placing an audio:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<embed type="audio/mpeg"
src="/build/audios/audio.mp3"
width="200"
height="100" />
</body>
</html>Example of the HTML <embed> tag for placing a video:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<embed type="video/mp4"
src="/build/videos/arcnet.io(7-sec).mp4"
width="300"
height="200"
title="Arcnet.io video" />
</body>
</html>Why the type attribute matters
The type attribute holds the MIME type of the embedded resource — the standard identifier the browser uses to pick the right content handler. Setting it lets the browser decide how to render the content (and skip downloading something it can't handle). Common values:
application/pdf— a PDF documentvideo/mp4— an MP4 videoaudio/mpeg— an MP3 audio fileimage/svg+xml— an SVG image
If type is omitted, the browser falls back to guessing from the file extension or the server's Content-Type header, which is less reliable.
Attributes
| Attribute | Value | Description |
|---|---|---|
| height | pixels | Defines the height of the embedded content. |
| src | URL | The path to the resource to embed. |
| type | MIME type | The MIME type of the embedded content (for example application/pdf or video/mp4), used to pick the right content handler. |
| width | pixels | Defines the width of the embedded content. |
The <embed> tag supports the Global attributes and the Event Attributes.
Obsolete and non-standard attributes
Avoid these — they are not part of the HTML5 standard and are ignored by modern browsers:
| Attribute | Status | What to use instead |
|---|---|---|
| align | Obsolete | CSS float and object-position |
| vspace, hspace | Obsolete | CSS margin |
| pluginspage | Non-standard | Nothing — plug-ins no longer exist, so there is nothing to download or install |
Accessibility
<embed> has no inherent accessible name, so screen readers may announce it as just "embedded content" with no further detail. Always add a title attribute describing what the resource is:
<embed type="application/pdf" src="/files/report.pdf"
width="600" height="800" title="2024 annual report (PDF)" />Because <embed> is an empty element, it cannot contain fallback content the way <object> and <iframe> can. If the resource fails to load there is nothing to show in its place. When a graceful fallback matters — for example a download link for users whose browser can't display the PDF — wrap the resource in an <object> element, which lets you place fallback HTML between its tags.