我可以将自定义属性添加到HTML标记吗? [英] Can I add custom attribute to HTML tag?
本文介绍了我可以将自定义属性添加到HTML标记吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将自定义属性添加到HTML标记,如下所示:< tag myAttri =myVal/>
$ b $ b
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // EN
http://www.w3.org/ TR / xhtml1 / DTD / xhtml1-transitional.dtd
[
<!ATTLIST标签myAttri CDATA#IMPLIED>
]>
#IMPLIED
表示它是可选的分组,或者您可以使用 #REQUIRED
等。
更多信息:
http://www.w3schools.com/xml/xml_dtd_attributes.asp
Can I add custom attribute to HTML tag like this: <tag myAttri="myVal" />
解决方案
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
这篇关于我可以将自定义属性添加到HTML标记吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文