且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我可以将自定义属性添加到HTML标记吗?

更新时间:2022-11-18 19:45:22

You can amend your !DOCTYPE declaration (i.e. 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