HTML data Attribute

By Jonathan Griffin. Editor, SEO Consultant, & Developer.

· 2 min read

Definition

The data attribute specifies the URL of the resource to display in the <object> element.

Applicable Elements

The data attribute can be used with the following elements:

HTML <object> data Attribute

The <object> tag is a container used to embed an external resource. The resource can be an image, nested HTML, or a resource handled by a plugin.

The data attribute, when used with the <object> element, specifies the URL of the resource.

Syntax

<object data="https://www.thewebmaster.com/"></object>

Usage

  • The data attribute should contain a valid URL linking to the resource you wish to embed in the <object> element.
  • At least one data attribute must be specified.

Values

Values can include:

  • A valid absolute or relative URL.

Examples

The following example demonstrates how to embed an image, HTML page, and movie file:

<!--Embed an image:-->
<object data="https://res.cloudinary.com/thewebmaster/image/upload/ar_16:10,c_fill,f_auto,g_auto,q_auto,w_300/image/google-update-march-2017.jpg" width="300" height="188"></object>

<!--Embed a HTML page:-->
<object data="https://www.thewebmaster.com/" width="500" height="200"></object>

<!--Embed a movie file:-->
<object data="https://file-examples-com.github.io/uploads/2020/03/file_example_WEBM_1920_3_7MB.webm"
       width="250"
       height="200"></object>

Specification

The data HTML specification for the <object> element is as follows:

Browser Support

The data attribute has the following browser support:

Desktop

ChromeEdgeFirefoxIEOperaSafari
dataYesYesYesYesYesYes

Mobile

Android WebviewChrome AndroidFirefox AndroidOpera AndroidiOS SafariSamsung Internet
dataYesYesYesYesYesYes