The
<embed>tag in HTML is used to embed external content such as videos, audio, PDFs, or interactive media (like SVGs or Flash) directly into a webpage.
It is a self-closing tag and doesn’t require a closing tag. It serves as a generic container for external resources when specific tags (like<video>or<audio>) are not suitable.
Syntax
<embed src="filename" type="mime/type" width="600" height="400">Attributes
| Attribute | Description |
|---|---|
| src | Specifies the path (URL) of the external file to embed. |
| type | Defines the MIME type of the embedded content (e.g., video/mp4, application/pdf). |
| width | Sets the width of the embedded content (in pixels). |
| height | Sets the height of the embedded content (in pixels). |
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML embed Tag Example</title>
</head>
<body>
<h2>Embedding a PDF File</h2>
<p>The following example embeds a PDF file directly inside the webpage:</p>
<embed src="/samples/sample.pdf" type="application/pdf" width="700" height="500">
<hr>
<h2>Embedding a Video File</h2>
<p>Below is an example of embedding a video file using the embed tag:</p>
<embed src="/samples/sample_video.mp4" type="video/mp4" width="640" height="360">
</body>
</html>Output
Browser Output
Use our TryIt Editor to see the output
Browser Support
Chrome | Firefox | Edge | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| ✅Yes | ✅Yes | ✅Yes | ✅Yes | ✅Yes | ✅Yes |
The PDF file appears inline with scroll and zoom options inside the page.
The video plays directly inside the defined area if supported by the browser.
Notes
<embed>is a generic container for external content; use it when a specialized element (like<audio>,<video>, or<object>) isn’t suitable.- Many use-cases (video/audio) are better handled by
<video>/<audio>because those provide built-in controls and better accessibility. - For documents (PDF) consider
<iframe>or<object>as alternatives — browser UI and print/zoom support may differ. - Some embedded content types may require browser plugins or specific MIME handlers; these cases can produce inconsistent behavior across browsers.
- Security: avoid embedding untrusted content. Use correct
typeand host files over HTTPS to prevent mixed-content issues. - Accessibility: provide fallback content and ensure embedded content is reachable via keyboard/screen readers when applicable.
- Sizing & responsiveness: use CSS (or wrapper elements) to make embedded content responsive; fixed
width/heightcan break layouts on small screens.
Conclusion
The <embed> tag is a versatile tool for embedding various types of media into a webpage.
While it provides a simple way to display external content like PDFs or videos, it lacks advanced playback controls — so for audio or video content, dedicated tags like <video> and <audio> are generally preferred.