The
<object>tag in HTML is used to embed external resources such as images, videos, PDFs, or even other web pages into a document.
It serves as a versatile container for any kind of media or plugin-based content.
Syntax
<object data="URL" type="MIME-type" width="value" height="value">
Alternative content displayed if the object cannot be loaded.
</object>Attributes
| Attribute | Description |
|---|---|
data | Specifies the URL of the resource to be embedded. |
type | Defines the MIME type of the embedded content (e.g., application/pdf). |
width | Sets the width of the embedded object. |
height | Sets the height of the embedded object. |
form | Associates the object with a form element. |
name | Assigns a name to the embedded object. |
usemap | Refers to an image map defined elsewhere in the document. |
typemustmatch | If present, requires the type attribute and the resource’s actual MIME type to match exactly. |
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML object Tag Example</title>
</head>
<body>
<h2>Embedding a PDF File Using <object> Tag</h2>
<object data="/samples/sample.pdf"
type="application/pdf"
width="600"
height="400">
Your browser does not support embedded PDF files.
<a href="/samples/sample.pdf">Download PDF</a> instead.
</object>
</body>
</html>Output
Browser Output
There is a visible embedded PDF viewer (if the browser supports it).
If not supported, the fallback text and link are displayed.
Use our Try It Editor to see the live output.
Browser Support
Chrome | Firefox | Edge | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| ✅Yes | ✅Yes | ✅Yes | ✅Yes | ✅Yes | ✅Yes |
The <object> tag is supported by all modern browsers, including Internet Explorer 9 and above.
However, the actual rendering depends on the content type and whether the browser supports that MIME type (e.g., PDF or image).
Notes
- The
<object>tag can embed images, PDFs, multimedia, and even web pages. - If the browser doesn’t support the specified media type, the fallback content between
<object>and</object>will be shown. - Use the
typeattribute to specify the correct MIME type — this helps browsers determine how to handle the content. - For embedding multimedia like audio and video, prefer
<audio>and<video>tags for better compatibility and control. <object>can be nested to provide multiple fallback sources.- Security note: avoid embedding untrusted external content directly to prevent potential script injection.
Conclusion
The <object> tag is a powerful and flexible HTML element for embedding various types of external media and documents.
While modern browsers support it well, it’s best used for specific cases such as PDFs or plugin-based files, not for audio/video playback where dedicated tags exist.