冒号 : 字符在 HTML(5) 中是否有效?
像这样:
<p he:llo="world" >Hello world</p>
在网上搜索后,我找到了这篇文章:
http://razzed.com/2009/01/30/valid-characters-in-attribute-names-in-htmlxml/
那说它是有效的,但他链接到这个 w3 文档:
http://www.w3.org/TR/2000/REC-xml-20001006#NT-Name
但是这篇文章的标题是“可扩展标记语言 (XML) 1.0(第二版)”——意思是 XML 而不是 HTML。
谁能帮我解释一下?
最佳答案
这用于 XML 命名空间,根据您引用的文档,不应将其用于其他目的:
The Namespaces in XML Recommendation [XML Names] assigns a meaning to names containing colon characters. Therefore, authors should not use the colon in XML names except for namespace purposes, but XML processors must accept the colon as a name character.
HTML5 supports both an XML mode and a non-XML mode .除了命名空间定界符外,我会远离冒号。
关于html - 冒号是: valid in attribute names for HTML(5)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16021123/