object

The HTML <object> element embeds an external resource and can contain fallback content for browsers or users that cannot use it.

What you will learn

Basic example with a fallback

<object data="guide.pdf" type="application/pdf">
  <p>This browser cannot display the PDF.
    <a href="guide.pdf">Download the guide</a>.
  </p>
</object>

The data attribute identifies the resource and type describes its media type. The child paragraph is available as fallback content when the resource cannot be rendered.

Choose a more specific element first

Image
Use img with meaningful alt text.
Audio or video
Use audio or video with controls and a suitable fallback.
Another web page
Use iframe only when embedding another browsing context is really intended.
General external data
Use object when its fallback behavior and resource type fit the content.

Fallback is part of the experience

Write fallback content that lets the user continue: offer a download link, a text alternative, or an explanation of what the embedded resource contains. Do not leave an empty box with no next step.

Security and trust

An embedded resource comes from a trust boundary that should be considered. Check the URL, type, permissions, privacy impact, and performance. Do not treat object as a security sandbox for untrusted content.

Common mistakes

Related pages