The data attribute on an <object> is the URL of the resource to embed — a PDF, image, SVG, or similar file. Pair it with type (MIME type) and optional width / height. At least one of data or type must be present.
Put fallback HTML inside <object> for when the resource cannot be shown. This attribute is not the same as data-* custom attributes.
Baseline · Widely available.
Not deprecated and not experimental. Standard <object> attribute across modern browsers.
Not data-*.
data-id, data-price, and similar names are custom data attributes on any element. The standalone data attribute is only the resource URL on <object>.
Syntax
HTML Syntax
syntax.html
<object data="URL" type="MIME">…</object>
URL may be relative or absolute. Child content is the fallback when the resource fails.
Values
Attribute Values
A valid URL string pointing at the embedded resource:
Assigning a URL tells the browser to load a different resource.
type can stay the same when both files share a MIME type.
Keep fallback content for cases where the new URL fails.
Edge Cases & Pitfalls
Use the right embed element, and do not confuse data with data-*.
vs data-*
Different features
data = object resource URL. data-* = custom metadata via dataset. See the data-* tutorial next.
prefer
Prefer dedicated tags
Use <img>, <video>, <audio>, or <iframe> when they fit. Reserve <object> for PDFs and cases that need nested fallback.
required
data or type
The HTML spec requires at least one of data or type. Providing both is the usual, clearer pattern.
CSP
Content Security Policy
Object embeds are governed by object-src (not img-src). A strict CSP can block the resource even when the URL is valid.
obsolete
Old object attributes
archive, classid, codebase, and similar plugin-era attributes are obsolete. Stick to data, type, size, and fallback content.
Compatibility
Browser Support
data is an HTML attribute on <object> in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
data
Widely available on object. PDF rendering quality depends on the browser’s built-in viewer.
97%Global support (approx.)
Google ChromeAll modern
Full support
Mozilla FirefoxAll modern
Full support
Apple SafariAll modern
Full support
Microsoft EdgeAll modern
Full support
OperaAll modern
Full support
Samsung InternetAll modern
Full support
Internet ExplorerAll versions
Supported
dataWidely supported
Bottom line: Safe for embedding with object. Always include fallback content for unsupported viewers or blocked resources.
Remember
Key Takeaways
Role: URL of the resource embedded by <object>.
Pair with:type, size attributes, and nested fallback HTML.
JS: read/write via objectElement.data.
Do not confuse with data-* custom attributes.
One line:data tells <object> which file to load — nest fallback content for when it cannot.
Frequently Asked Questions
On an object element, data is the URL of the external resource to embed (PDF, image, SVG, and similar). At least one of data or type must be set.
Only object. It is not the same as data-* custom attributes used on any element for script metadata.
No. data is a single attribute for an object resource URL. data-* attributes (data-id, data-price, …) store custom values and map to element.dataset in JavaScript.
Prefer img for images and video/audio for media. Use object with data when you need fallback content inside the tag (common for PDFs) or a generic embed.
Yes. Assign a URL string to objectElement.data to point the embed at another resource.
Older attributes like archive, classid, and codebase are obsolete. The data attribute itself is current and Baseline widely available.