Is it OK to add your own attributes to HTML elements? [duplicate]

There has been much discussion about this:

At the end of the day, I am on the camp that believes data attributes are the best way to go. They are being introducted in HTML5 to avoid name conflicts. Essentially, if you want to store anything data related you just prepend “data-” on the attribute name:

<div class="user" data-userid="5"></div>

The only con to the whole thing is then that your XHTML won’t validate, but I honestly don’t care about that stuff. (That’s right, I said it)

Leave a Comment