I like the concept of the data-* attributes introduced with HTML5. I don’t like how they are implemented. Just one character had to be changed.
The data-* attributes “are intended to store custom data private to the page or application, for which there are no more appropriate attributes or elements” (quoted from HTML5 spec). The author of a web page may use arbitrary attributes, whose names begin with data- followed by some more characters. For example, if you want to store something you call “mydata” within your HTML code you might use an attribute named “data-mydata”. Obviously the string “data-” is required to prevent conflicting attribute names. Accordingly “data-” is nothing else than a namespace prefix.
Namespaces? Yes, they’ve already been invented. Probably several times. For markup languages they have been invented/introduced by W3C more than a decade ago. Those namespaces use a prefix too. But it’s separated from the custom name by a colon (:) not a dash (-). The mydata attribute would look like “data:mydata”. For the namespaces to be namespace spec compliant, the prefix must be declared in the HTML document. The authors of the HTML5 spec don’t seem to like that. Ok, but why the dash instead of the colon? What’s the problem to define the feature as “data:* attributes” in the HTML5 standard? With a dash, the data attributes can’t be specified in a DTD; with a colon, they can.
From my point of view it would be even easier to change the namespace spec in order to allow namespace prefixes that have not been declared. The rule could be: Every undeclared prefix gets a “temporary”, document wide unique identifier.
Some say, HTML5 can’t be expressed with a DTD/Schema. When it comes to data-* attributes, it looks like they first decided, HTML5 shall not be expressed in terms of XML/SGML, and later say it can’t.