Why should I prepend my custom attributes with "data-"?
Posted
by Horace Loeb
on Stack Overflow
See other posts from Stack Overflow
or by Horace Loeb
Published on 2010-03-15T21:21:10Z
Indexed on
2010/03/15
23:29 UTC
Read the original article
Hit count: 433
So any custom data attribute that I use should start with "data-":
<li class="user" data-name="John Resig" data-city="Boston"
data-lang="js" data-food="Bacon">
<b>John says:</b> <span>Hello, how are you?</span>
</li>
Will anything bad happen if I just ignore this? I.e.:
<li class="user" name="John Resig" city="Boston"
lang="js" food="Bacon">
<b>John says:</b> <span>Hello, how are you?</span>
</li>
I guess one bad thing is that my custom attributes could conflict with HTML attributes with special meanings (e.g., name
), but aside from this, is there a problem with just writing "example_text" instead of "data-example_text"? (It won't validate, but who cares?)
© Stack Overflow or respective owner