Live Preview
Embedded audio via <embed> (browser-dependent rendering):

By the end of this tutorial, you’ll embed external media and documents into web pages with the <embed> element.
The <embed> tag is a versatile HTML element for inserting external content—such as multimedia files, PDFs, and other resources—directly within a web page. This guide walks through syntax, attributes, and best practices.
Use src and type on the void <embed> element.
Control size with width and height attributes.
Embed sound and video files when native tags are not suitable.
Display PDF files inline in the browser viewport.
Know when to embed media vs nest another HTML page.
Verify MIME types and rendering across browsers.
<embed> Tag?The embed element (<embed>) embeds external content seamlessly into a web page. It supports various media types including audio, video, PDF documents, and—historically—browser plugin content.
For audio and video playback with controls and accessibility, use <audio> and <video>. Reach for <embed> for PDFs and other external content those tags do not handle.
<embed> is a void element—it has no closing tag. The browser loads the resource pointed to by src and renders it using the MIME type from type.
Provide src and type in the opening tag. Here is a basic audio example:
<embed src="audio.mp3" type="audio/mpeg"><embed> is a void element—do not use a closing tag.type to the correct MIME type so browsers handle the resource properly.width and height for visual media and documents.| Attribute | Example | Purpose |
|---|---|---|
src | src="video.mp4" | URL of the embedded resource |
type | type="video/mp4" | MIME type of the content |
width | width="640" | Rendered width in pixels |
height | height="360" | Rendered height in pixels |
| Audio MIME | audio/mpeg | MP3 files (not audio/mp3) |
| PDF MIME | application/pdf | Inline PDF documents |
<embed> vs <iframe>Both insert external content, but they serve different purposes:
| Feature | <embed> | <iframe> |
|---|---|---|
| Element type | Void element | Container with closing tag |
| Typical content | Media files, PDFs | HTML pages, maps, widgets |
| Nested browsing context | No | Yes — separate document |
| Key attributes | src, type | src, title, sandbox |
<embed> vs <audio> / <video>For sound and moving images, native HTML5 media tags are usually the better choice:
| Need | Recommended tag | Why |
|---|---|---|
| Audio with controls | <audio> | Native player, source fallbacks, accessibility |
| Video with controls | <video> | Native player, poster, track captions |
| PDF document | <embed> | No dedicated PDF element in HTML |
| Legacy plugin content | <embed> (historical) | Flash and plugins are deprecated today |
The <embed> tag supports these key attributes plus global attributes such as title and class:
src RequiredURL of the file or resource to embed in the page.
src="video.mp4"type MIMEMIME type of the embedded content—helps the browser choose the correct handler.
type="video/mp4"width LayoutWidth of the embedded content area in pixels or CSS units.
width="640"height LayoutHeight of the embedded content area in pixels or CSS units.
height="360"<embed src="video.mp4" type="video/mp4" width="640" height="360">Always match type to the actual MIME type of the file—for example audio/mpeg for MP3, not audio/mp3.
Audio, video, PDF, and legacy plugin patterns with copy-ready code and live previews.
Embedded audio via <embed> (browser-dependent rendering):
Include an audio file within your webpage using the <embed> tag.
<embed src="background_music.mp3" type="audio/mpeg">Use <embed> to integrate audio clips, presentation videos, inline PDF manuals, and—in legacy pages—plugin-based interactive content. For everyday audio and video players, prefer <audio> and <video>.
Embed videos with explicit dimensions for a more interactive and engaging user experience.
<embed src="presentation.mp4" type="video/mp4" width="800" height="450">Display a PDF inline when you need a document viewer without leaving the page.
<embed src="manual.pdf" type="application/pdf" width="600" height="400">Historically, <embed> loaded Flash and other browser plugins. Flash is deprecated—keep this pattern only when maintaining very old content.
<embed src="interactive_app.swf" type="application/x-shockwave-flash" width="400" height="300">Size and layout embedded content with width and height attributes or CSS on a wrapper:
width / height Control embed dimensionsmax-width: 100% Responsive embedsaspect-ratio Keep video proportionsdisplay: block Remove inline gap/* Responsive video embed */
.media-embed {
max-width: 100%;
display: block;
}
.media-embed embed {
width: 100%;
height: auto;
aspect-ratio: 16 / 9;
}Sized embed preview
Embedded content needs extra care for all users:
Point src at the file URL and set the matching MIME type.
The user agent fetches the file and selects a handler based on MIME type.
Audio, video, PDF, or legacy plugin UI appears at the specified width and height.
Users interact with media or documents without navigating away from your site.
The <embed> element is supported in all modern browsers. Internet Explorer has partial support with limitations depending on the embedded content type.
Chrome, Firefox, Safari, Edge, and Opera fully support embed for common media and PDF types. Test your specific file format in each target browser.
Bottom line: Ship embeds with confidence in modern browsers. Match MIME types correctly, set dimensions, and test in IE only if you still support legacy environments.
The <embed> tag is a powerful tool for incorporating external content seamlessly into your web pages. Whether you are embedding multimedia or PDF documents, understanding its capabilities and best practices helps you create a rich and engaging user experience.
Set accurate MIME types, specify width and height, prefer <audio> and <video> for native media playback, and test across browsers before you ship.
type to the correct MIME typewidth and height for visual embeds<audio> and <video> for media when possibleaudio/mp3<embed>Bookmark these before you ship — they’ll keep your embedded content reliable and accessible.
<embed> inserts media and documents into the page.
URL and MIME type tell the browser what to load.
AttributesSet width and height for video and PDF embeds.
LayoutUse audio and video for everyday media playback.
Best practiceEmbed is common for inline PDF documents.
PatternModern browsers: full support. IE: partial.
Compatibilitysrc and type attributes.embed loads media and documents directly. iframe nests another HTML browsing context, such as a web page or widget.<audio> and <video> for media with controls and accessibility. Use <embed> for PDFs and other content those tags do not cover.audio/mpeg, not audio/mp3. Accurate MIME types help browsers handle files correctly.Embed audio, video, and PDF files in the interactive HTML editor.
6 people found this page helpful