HTML data attribute

HTML data attribute

In this tutorial, we will learn about data attribute in HTML with the help of examples.

data attribute

The data-* attribute is used to store custom data private to the page or application and gives us the ability to embed custom data attributes on all HTML tags.

The data-* attributes mainly consists of two parts :

  • There must be at least one character long after the prefix data-.
  • The attribute name should not contain any uppercase letters.
  • The attribute value can be any string.


<a data-* = "mydata">......</a>

Attribute values

Value Description
someStringValue Used to specify the value of the attribute(as a string)

Next Tutorial

We hope that this tutorial helped you develop better understanding of the concept of data Attribute in HTML.

Keep Learning : )

In the next tutorial, you'll learn about HTML dir Attribute.

- Related Topics