-2

What are these types of attributes called?

data-role=
data-theme=
data-position=
data-display=

Those specific attributes are coming out of Phonegap but I've seen these in other web frameworks. Are these custom or part of CSS3?

Dawson Loudon
  • 6,029
  • 2
  • 27
  • 31
4thSpace
  • 43,672
  • 97
  • 296
  • 475

1 Answers1

2

From the Mozilla Developer Network:

HTML5 is designed with extensibility for data that should be in the HTML, but not visible. data-* attributes allow us to store extra information on standard, semantic HTML elements without polluting the class name.

The syntax is easy. Say you have an article and you want to store some extra information that doesn’t have any visual representation. Just use data attributes for that:

<article
  id="electriccars"
  data-columns="3"
  data-indexnumber="12314"
  data-parent="cars">
...
</article>
Community
  • 1
  • 1
John Conde
  • 217,595
  • 99
  • 455
  • 496