HTML Guides for data
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
<object> elements require both the data and type attributes to be valid according to W3C HTML specifications.
The <object> element is used to embed external resources, such as images, videos, PDFs, or other media—often for plugins or fallback content. The data attribute specifies the resource URL, while the type attribute describes its MIME type (such as "image/svg+xml" for SVG images, or "application/pdf" for PDFs). Supplying both attributes allows browsers and assistive technologies to correctly interpret and display the embedded content, ensuring accessibility and standards compliance.
Correct usage example:
<object data="example.pdf" type="application/pdf" width="600" height="400">
<p>Your browser does not support PDFs. <a href="example.pdf">Download the PDF</a>.</p>
</object>
Incorrect usage examples (missing attributes):
<!-- Missing type attribute -->
<object data="example.svg"></object>
<!-- Missing data attribute -->
<object type="image/svg+xml"></object>
Corrected example for embedding SVG:
<object data="image.svg" type="image/svg+xml"></object>
To fix validator errors, always include both the data and type attributes in <object>.
Ready to validate your sites?
Start your free trial today.