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-*?

1
  • 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. Commented Jun 13, 2013 at 16:27

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Why the big ones ignores valid HTML ?
They probably don't care, but until you become one of them - use the data attributes.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.