👀 Live Preview
Simulated embedded resource area with dimensions:

The <object> tag embeds external resources into HTML documents. This guide covers syntax, key attributes, fallback content, common media use cases, and when to prefer native img, video, or iframe elements.
PDFs, SVG, audio, video.
URL and MIME type attributes.
Nested HTML when embed fails.
width and height control.
Compare embedding approaches.
MIME types and accessibility.
<object> Tag?The <object> tag is a versatile HTML element for embedding external resources or multimedia content within a webpage. It provides a generic container for images, audio, video, PDFs, or even entire HTML documents using the data and type attributes.
Use <img> for images, <audio> / <video> for media, and <iframe> for external pages. <object> shines for PDF embedding and resources that need nested fallback content.
Specify the MIME type with type and the resource URL with data. Place fallback content inside the element:
<object type="media_type" data="URL">
<!-- Fallback content or alternative text goes here -->
</object>data points to the external file or URL.type sets the MIME type (e.g. application/pdf).<object /> is valid when no fallback is needed.| Topic | Code Snippet | Notes |
|---|---|---|
| Basic object | <object data="file" type="..."> | With fallback inside |
type="application/pdf" | Common use case | |
| SVG | type="image/svg+xml" | Or use img |
| Audio | type="audio/mpeg" | Prefer audio tag |
| Dimensions | width="640" height="360" | Layout control |
| Fallback | <p>Download link</p> | Inside object |
<object> vs Other Embed Tags| Element | Best For | Fallback |
|---|---|---|
<object> | PDFs, plugin resources | Nested HTML children |
<embed> | Simple plugin embeds | None (void element) |
<iframe> | External web pages | noscript / link outside |
<img> / <video> | Images and media | alt / inner HTML |
Key attributes for the <object> element:
<object type="audio/mpeg" data="audiofile.mp3" width="300" height="40" class="audio-player"></object>type MIMESpecifies the MIME type of the embedded content.
type="application/pdf"data RequiredURL of the external resource to embed.
data="document.pdf"width / height LayoutSets dimensions of the embedded content area.
width="640" height="360"class / style GlobalApply CSS classes or inline styles to the object element.
class="pdf-viewer"Including fallback content within the <object> tag is crucial when the browser cannot render the embedded resource. This ensures a meaningful user experience with download links or descriptive text.
<object type="application/pdf" data="document.pdf">
<p>It appears you don’t have a PDF plugin for this browser. You can <a href="document.pdf">download the PDF file.</a></p>
</object>It appears you don’t have a PDF plugin for this browser. You can download the PDF file.
Embedding images, audio, and video with the object element. For production sites, prefer native HTML5 media tags where noted.
Simulated embedded resource area with dimensions:
Use <object> to embed SVG images, audio files, and video content. Specify the URL in data, set the MIME type, and define width / height for layout control.
Embed SVG or unconventional image formats. For standard raster images, <img> is usually simpler.
<object type="image/svg+xml" data="image.svg" width="200" height="100"></object>Embed audio with object. For new projects, the native <audio> element is recommended.
<object type="audio/mpeg" data="audiofile.mp3" width="300" height="40"></object>Integrate video with object. Prefer <video> with controls for better browser support and accessibility.
<object type="video/mp4" data="videofile.mp4" width="640" height="360"></object>object.video and audio have built-in keyboard controls.Point data to the file URL and type to the MIME type.
The user agent attempts to render the embedded content in the object area.
Nested HTML inside object displays when loading fails.
Users always have a path forward—view the file or download it.
The <object> element is supported in all major browsers. Actual rendering depends on the resource type—PDF plugins vary, while native media is better served by video and audio.
Chrome, Firefox, Safari, Edge, Opera, and Internet Explorer all support the <object> tag. Plugin-dependent content (like PDF) may behave differently per browser.
Bottom line: The tag works everywhere. Always add fallback content and choose the right native element for images and media when possible.
Mastering the <object> tag empowers you to integrate diverse content types into your web pages. Whether it’s PDFs, SVG, audio, or video, the <object> tag offers a standardized approach with built-in fallback support—especially valuable for documents and specialized embeds.
<object>Bookmark these before you embed external resources.
External resources via data URL.
BehaviorMIME type and resource URL.
AttributesNested content when embed fails.
ResilienceControl embed dimensions.
Layoutimg, video, audio when possible.
Modern HTMLElement works in all browsers.
Compatibilityaudio/mpeg, not the non-standard audio/mp3.Practice <object> with PDF fallback in the Try It editor.
6 people found this page helpful