Can I add custom attribute to HTML tag?
我可以像这样将自定义属性添加到HTML标记: <tag myAttri="myVal" />
You can amend your !DOCTYPE declaration (ie DTD) to allow it, so that the [XML] document will still be valid:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
[
<!ATTLIST tag myAttri CDATA #IMPLIED>
]>
#IMPLIED
means it is an optional attribue, or you could use #REQUIRED
, etc.
more info here:
http://www.w3schools.com/xml/xml_dtd_attributes.asp
You can add custom attributes to your elements at will. But that will make your document invalid.
In HTML 5 you will have the opportunity to use custom data attributes prefixed with data-
.
No, this will break validation.
In HTML 5 you can/will be able to add custom attributes. Something like this:
<tag data-myAttri="myVal" />
链接地址: http://www.djcxy.com/p/88064.html
上一篇: Jquery自定义属性
下一篇: 我可以将自定义属性添加到HTML标记吗?