Better alternative for embedding external content. Learn more →
<embed> ElementThe embed element embeds external content at the specified point in the document. Historically used for browser plugins like Flash, it’s now primarily used for embedding PDFs and SVG files, though modern alternatives are often preferred.
<embed src="file.pdf" type="application/pdf">The <embed> element is a void element (self-closing) and does not have a closing tag or child content.
| Attribute | Description | Example |
|---|---|---|
src | URL of the external resource | src="document.pdf" |
type | MIME type of the embedded content | type="application/pdf" |
width | Width in pixels | width="600" |
height | Height in pixels | height="400" |
title | Accessible description (recommended) | title="Annual Report PDF" |
The <embed> element accepts any attributes, which are passed to the plugin or application handling the content:
<!-- PDF with custom parameters --><embed src="document.pdf" type="application/pdf" toolbar="0" navpanes="0" scrollbar="0">
<!-- Flash (legacy example) --><embed src="animation.swf" type="application/x-shockwave-flash" quality="high" wmode="transparent">PDF URL Parameters:
#page=3 - Open to specific page#zoom=150 - Set zoom level (percentage)#toolbar=0 - Hide toolbar#navpanes=0 - Hide navigation panes#scrollbar=0 - Hide scrollbar#view=FitH - Fit width#pagemode=bookmarks - Show bookmarks<embed src="document.pdf" type="application/pdf" width="600" height="400"><iframe src="document.pdf" width="600" height="400" title="PDF Document"> <p>Your browser does not support PDFs. <a href="document.pdf">Download the PDF</a>.</p></iframe><!-- Legacy QuickTime embed --><embed src="movie.mov" type="video/quicktime" width="640" height="480" controller="true" autoplay="false" pluginspage="http://www.apple.com/quicktime/download/">| Content Type | Legacy (<embed>) | Modern Alternative |
|---|---|---|
<embed src="file.pdf"> | <iframe src="file.pdf"> or <object> | |
| SVG | <embed src="file.svg"> | <img src="file.svg"> or inline SVG |
| Video | <embed src="video.mp4"> | <video><source src="video.mp4"></video> |
| Audio | <embed src="audio.mp3"> | <audio><source src="audio.mp3"></audio> |
| Flash | <embed src="file.swf"> | Use HTML5/JavaScript/CSS instead |
| Images | <embed src="image.jpg"> | <img src="image.jpg"> |
| External HTML | <embed src="page.html"> | <iframe src="page.html"> |
Rare Cases Only: Legacy system compatibility, specific plugin requirements, quick PDF embedding (though <iframe> is better).
Limitations: No fallback content, poor accessibility, browser-dependent behavior, no standardized attributes.
Best For: Embedding HTML pages, PDFs with fallback, third-party content, or when security isolation is needed.
Advantages: Fallback content support, better security (sandbox), standardized attributes, excellent browser support.
Best For: Embedded content with fallback, SVG with fallback, or complex multimedia with alternatives.
Advantages: Multiple fallback levels, nested fallback support, better for progressive enhancement.
Since <embed> doesn’t support fallback content, provide alternatives nearby:
<embed src="presentation.pdf" type="application/pdf" width="800" height="600" title="Q4 Sales Presentation - Annual Review">
<embed src="chart.svg" type="image/svg+xml" width="600" height="400" title="Revenue Growth Chart 2024" aria-label="Bar chart showing 15% revenue growth"><!-- No title - screen readers can't describe content --><embed src="presentation.pdf" type="application/pdf" width="800" height="600">
<!-- Generic title - not helpful --><embed src="chart.svg" type="image/svg+xml" title="Image">Security Best Practices:
<video>, <audio>, <img>)<iframe> with sandbox for external contentAlways specify the correct MIME type to prevent content type confusion attacks:
<embed src="document.pdf" type="application/pdf" width="600" height="400">
<embed src="image.svg" type="image/svg+xml" width="200" height="100"><!-- No type specified - browser guesses --><embed src="unknown-file.bin" width="600" height="400">| Feature | Chrome | Firefox | Safari | Edge |
|---|---|---|---|---|
<embed> element | 1+ | 1+ | 1+ | 12+ |
| PDF embedding | 1+ | 19+ | 5+ | 12+ |
| SVG embedding | 4+ | 4+ | 5+ | 12+ |
| Flash plugin | ❌ Removed 88+ | ❌ Removed 85+ | ❌ Removed 14+ | ❌ Removed 88+ |
| Java plugin | ❌ Removed 45+ | ❌ Removed 52+ | ❌ Removed 12+ | ❌ Removed |
| QuickTime plugin | ❌ Deprecated | ❌ Deprecated | ❌ Deprecated | ❌ Deprecated |
| MIME Type | Description | Modern Alternative |
|---|---|---|
application/pdf | PDF documents | Use <iframe> or <object> |
image/svg+xml | SVG vector images | Use <img> or inline SVG |
application/x-shockwave-flash | Flash (deprecated) | Use HTML5/CSS/JavaScript |
video/mp4 | MP4 video | Use <video> element |
audio/mpeg | MP3 audio | Use <audio> element |
video/quicktime | QuickTime (deprecated) | Use <video> with MP4 |
application/x-java-applet | Java (removed) | Use modern web technologies |
<embed src="animation.swf" type="application/x-shockwave-flash" width="800" height="600" quality="high" wmode="transparent"><!-- Use CSS animations, JavaScript, or Canvas --><canvas id="animation" width="800" height="600"></canvas><script> const canvas = document.getElementById('animation'); const ctx = canvas.getContext('2d'); // Draw animation with JavaScript</script>
<!-- Or use video for animations --><video width="800" height="600" autoplay loop muted> <source src="animation.mp4" type="video/mp4"> <source src="animation.webm" type="video/webm"></video><embed src="document.pdf" type="application/pdf" width="600" height="400"><!-- No fallback possible --><object data="document.pdf" type="application/pdf" width="600" height="400"> <p>Your browser doesn't support PDFs. <a href="document.pdf">Download the PDF</a>.</p></object>
Better alternative for embedding external content. Learn more →
Embedded content with fallback support. Learn more →
Native video playback without plugins. Learn more →
Native audio playback without plugins. Learn more →