The <embed>
tag is used to embed external content such as multimedia (videos, audio), PDFs, or interactive applications (like Flash, SVG, or other plugins) directly into a webpage.
It acts as a container for non-HTML content.
✅ Basic Syntax
<embed src="file.pdf" type="application/pdf" width="600" height="500">
📍 Result:
Displays a PDF document embedded within the webpage.
🧩 Common Uses
Content Type | MIME Type |
---|---|
PDF document | application/pdf |
MP3 audio | audio/mpeg |
MP4 video | video/mp4 |
SVG images | image/svg+xml |
Flash (deprecated) | application/x-shockwave-flash |
🎨 Example: Embedding a YouTube Video
While YouTube prefers <iframe>
, here’s how you could use <embed>
(not recommended nowadays):
<embed
src="https://www.youtube.com/v/VIDEO_ID"
width="560"
height="315"
type="application/x-shockwave-flash">
⚠️ Note: Flash is now deprecated, and this method is outdated. Use <iframe>
for YouTube embeds.
⚙️ Attributes of <embed>
Attribute | Description |
---|---|
src | Path to the external file/resource |
type | MIME type of the content |
width | Width of the embedded content |
height | Height of the embedded content |
⚠️ Important Notes
- The
<embed>
tag is self-closing (no closing tag). - It’s supported in all modern browsers.
- For multimedia,
<video>
and<audio>
are now preferred over<embed>
due to better control and accessibility. - Not all file types are embeddable — depends on the browser and OS support.
✅ Summary
Tag | <embed> |
---|---|
Purpose | Embed external, non-HTML content |
Semantic? | ❌ No |
Common Uses | PDFs, SVGs, media, plugins |
Alternatives | <iframe> , <object> , <video> |