5

AngularJS gives the option of, but does not use the data- prefix in their examples or mandate the use of it. Should I include the data- prefix in my project and why?

Is it still valid HTML if I don't use data-*?

Mikael Dúi Bolinder
  • 2,080
  • 2
  • 19
  • 44
MR.ABC
  • 4,712
  • 13
  • 44
  • 88
  • Not a constructive question but an opinion poll. To make the question constructive, you should present the question more clearly (what exactly are you using) and specify the criteria to be applied. – Jukka K. Korpela Jun 13 '13 at 16:27

1 Answers1

6

Many libraries like knockout, angular etc. do not use the data- prefix.

Knockout uses data-*: "<span data-bind="text: myMessage">"

Angular uses data-*: "the directive can be prefixed with x-, or data- to make it HTML validator compliant" (shame they don't understand that it is for compliance with HTML and not with the validator).

Should i include the data- prefix ?

Yes, you should write valid HTML. If you are making up attributes, use data- ones.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335