本问题已经有最佳答案,请猛点这里访问。
Possible Duplicate:
Custom attributes - Yea or nay?
可以为HTML元素分配任意属性吗?
例如:
是的,您可以具有自定义属性。
但是您的HTML不会被验证。
为避免此问题,只需在属性的前面加上data-即可验证您的HTML ...
下一个答案让我对这个示例有些担心,因为根据该规范,该规范禁止使用大写字母
@Sushanth-"您的HTML不会被验证"是什么意思?
是的,但是它们必须以data-为前缀。
A custom data attribute is an attribute in no namespace whose name
starts with the string"data-", has at least one character after the
hyphen, is XML-compatible, and contains no characters in the range
U+0041 to U+005A (LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z).
W3C HTML5规范:http://dev.w3.org/html5/spec/single-page.html?utm_source = dlvr.it&utm_medium = feed#embedding-custom-non-visible-data-with-the-data-*- 属性
是。
John Resig发表的HTML5自定义数据属性
http://ejohn.org/blog/html-5-data-attributes/
HTML4属性
http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2