References

Beginner-friendly references for web development, with live, editable examples.

The HTML <object> data attribute

Attribute All modern browsers Updated
Quick answer

The HTML data attribute specifies the URL of the resource the object embeds. It is used on the <object> element.

Overview

The data attribute specifies the URL of the resource the object embeds. It applies to the <object> element.

Do not confuse it with the global data-* attributes; this data is the resource URL for <object> only.

Syntax

<object data="file.pdf" type="application/pdf"></object>

Values

Value
A URL pointing to the resource.

Best practices

  • Give every <iframe> a descriptive title.
  • Sandbox untrusted content with sandbox, and avoid combining allow-scripts with allow-same-origin for untrusted sources.
  • Grant only the features a frame needs with the allow attribute.
  • Defer off-screen frames with loading="lazy".

Frequently asked questions

What does the data attribute do?
Sets the URL of an embedded object.
How do I make an iframe secure?
Restrict untrusted content with sandbox, grant minimal features with allow, and never pair allow-scripts with allow-same-origin for untrusted sources.
How do I embed inline HTML in an iframe?
Use the srcdoc attribute to supply the HTML directly instead of a src URL.
Which elements use the data attribute?
It is an element-specific attribute, used on the <object> element.