The <object> Element
As defined in the HTML Living Standard, the <object> element is a general-purpose container for an external resource. It is more flexible than <embed> because it allows for fallback content.
<object data="document.pdf" type="application/pdf" width="100%" height="500px">
<p>Fallback content for browsers that cannot render the PDF.</p>
</object>
View HTML Living Standard: The object element
Accessibility: The Power of Fallbacks
The primary accessibility advantage of <object> over <embed> is the ability to provide fallback content inside the tag.
WCAG Principle: Robustness
Success Criterion 4.1.1 (Parsing): While parsing is less critical in HTML5, providing a meaningful fallback ensures that users with older browsers or assistive technologies that cannot process the external resource still receive the core information.
Always ensure the fallback content is a text-based equivalent of the object's purpose.
Usage & Best Practices
- Data Attribute: The
dataattribute specifies the URL of the resource. - Type Attribute: The
typeattribute helps the browser decide if it can handle the resource before attempting to load it. - Avoid for Media: For audio and video, always prefer
<audio>and<video>as they provide native accessibility controls (captions, transcripts).