Skip to main content

HTML Tags

HTML <object> Tag

Written by Updated

The <object> element embeds an external resource such as a PDF or image and can provide accessible fallback HTML when the resource cannot be displayed.
For audio, video, or another webpage, prefer the dedicated <audio>, <video>, or <iframe> element.

Syntax

html

<object data="URL" type="MIME-type" width="value" height="value">
  Alternative content displayed if the object cannot be loaded.
</object>

Attributes

AttributeDescription
dataSpecifies the URL of the resource to be embedded.
typeDefines the MIME type of the embedded content (e.g., application/pdf).
widthSets the width of the embedded object.
heightSets the height of the embedded object.
formAssociates the object with a form element.
nameAssigns a name to the embedded object.

Example

Embedding a PDF File Using <object> Tag

html

<object data="https://ik.imagekit.io/html5andcss3/lesson-samples/sample.pdf" type="application/pdf" width="600" height="400">
  <p>Your browser does not support embedded PDF files. <a href="https://ik.imagekit.io/html5andcss3/lesson-samples/sample.pdf">Download PDF</a> instead.</p>
</object>

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

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 type attribute 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

Use <object> when you need to embed a supported external resource and provide fallback HTML.
Use dedicated elements for audio, video, and webpages, and do not use obsolete <param> children.