Reputation: 10939
I've been reading up on custom data attributes for html webpages (one example of the numerous ones). From what I can tell going forward this is likely the best solution.
<div data-my_attrib="stackoverflow"></div>
My question pertains to backwards compatibility.
Supposedly the html standard specifies that unknown attributes should be ignored (I've read this comment multiple times, haven't actually read the standard myself :P), but are there any known browsers (including past versions, both mobile and PC-based) which might have problems with the new custom attribute specification? If so, which ones?
Additionally, are there any known possible issues where data-something
might already be defined for old browsers (something
is an arbitrary placeholder)? The focus is on core browser functionality (including standard addons shipped with the browser), ignore website scripts/libraries like JQuery and the likes.
Upvotes: 4
Views: 919
Reputation: 324650
Unknown attributes are ignored in that they don't do anything, but they are still available for getAttribute
to retrieve.
I'm fairly sure it's safe to assume that data-*
is not used for anything else - otherwise they would have chosen a different identifying keyword that didn't conflict with something else.
Upvotes: 4
Reputation: 70075
There are no known issues with backwards compatibility for data-*
attributes, certainly not with any browser you are actually likely to run into.
The whole don't-break-old-browsers thing is kind of one of the guiding principles of HTML5.
Upvotes: 3