Is it "ok" to add attributes to various tags to use in JavaScript DOM parsing?
For example if I want to have required fields in a form, would it be a bad practice if I would do this:
<input type="submit" name="name" required="true"/>
Thank yo开发者_如何学运维u.
From that question:
HTML 5 explicitly allows custom attributes that begin with data
. So, for example, <p data-date-changed="Jan 24 5:23 p.m.">Hello</p>
is valid. Since it's officially supported by a standard, I think this is the best option for custom attributes. And it doesn't require you to overload other attributes with hacks, so your HTML can stay semantic.
Source: http://www.w3.org/TR/html5/elements.html#embedding-custom-non-visible-data-with-the-data-attributes
精彩评论