It makes sense to make underscore-prefixed (_
) custom HTML attributes formally valid:
<div _foo="bar" _lorem="ipsum" _boolean></div>
Facts and advantages
data-
).data-
(custom attributes are for data to the same extent as all standard attributes are) or with any other letter-based prefix like my-
.data-
prefix is omitted/ignored in practice
The currently allowed data-
prefix is in fact too long (5-times longer than _
) and therefore just omitted/ignored in practice (e. g. the Angular JS library uses ng-*
attributes), so HTML markup inevitably gets invalid anyway (and not future-proof compared with the underscore prefix).
data-
and dataset
Underscore-prefixed attributes should not affect data-
prefixed attributes and/or the dataset
DOM property in any way, and vice versa. _
and data-
prefixed attributes should just coexist.
Alternatively, hyphen (-
) prefix could be used instead of underscore (_
), but actually, both work in all browsers, both are future-proof, so both should be formally valid. Underscore would just be enough.
Also, from the two, the underscore prefix is reportedly the only XML-compatible option that is also confirmed by Simon Pieters (@zcorpan).
jhpratt, Marat-Tanalin, jonathantneal, calvinjuarez and vphantomrianby64, nuxodin and oliviarinat
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4