/

HTML / CSS / JavaScript Tutorial

HTML Standard attribute: data-*

[this page | pdf | back links]

The HTML data-* attribute provides a means of storing custom data specific to a page. It can be applied to all HTML elements and can be accessed by JavaScript embedded within the page.

 

The data-* attributes have two components:

 

(a)    The name, which is the * part of the overall attribute name, which should not contain any uppercase letters

(b)   The attribute value, which can be any string

 

E.g.

 

<ul>

  <li data-continent="Europe">Spain</li>

  <li data-continent="Asia">Japan</li>

</ul>

 


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile