<object>, <embed>
Embed an external file — for example, a PDF — using the browser's own viewer.
Syntax
<object data="file.pdf" type="application/pdf">fallback</object>Attributes
| Parameter | Type | Description |
|---|---|---|
| data | URL | The file address for `<object>`. |
| src | URL | The file address for `<embed>`. |
| type | MIME type | The file type. |
| width, height | number | The size of the area. |
Examples
A PDF with a fallback link:
<object data="/media/menu.pdf" type="application/pdf" width="300" height="150">
<p>Cannot show the PDF. <a href="/media/menu.pdf">Download the menu</a>.</p>
</object>The same with <embed> (no fallback content):
<embed src="/media/photo-400x250.jpg" type="image/jpeg" width="200">Notes
These tags are rarely needed today: images have <img>, video has <video>, pages have <iframe>. The advantage of <object> is that it shows its content when the file cannot be opened. <embed> is single and has no fallback.
See also
In the tutorial
- Embedding pages: iframe — The iframe tag — embedding another page, a map or a video, size and title, srcdoc, lazy loading and sandbox restrictions.