HTML global attribute data-*

The data-* attributes stores custom data.

The stored data can be used in the page's JavaScript.

The attribute name should not contain any uppercase letters, and must be prefixed with "data-".

The attribute value can be any string.

What's new in HTML5

The data-* attributes are new in HTML5.


<element data-*="value">

Attribute Values

the value of the attribute

Browser compatibility

data-* Yes Yes Yes Yes Yes


<!DOCTYPE html>
function showDetails(animal) {<!--  w w  w  . j a v  a  2 s  .  com-->

<p onclick="showDetails(this)" id="owl" data-animal-type="it is a test.">Click me</li>


Click to view the demo