html - 冒号是: valid in attribute names for HTML(5)?

标签 html

冒号 : 字符在 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/

相关文章:

html - 960 网格在 Internet Explorer 中左对齐

html - 将数千张小图像加载到网页上

css - Bootstrap 中不能出现 "pull-right"图标字形

javascript - HTML:通过 JavaScript 添加 <STYLE> 和 <SCRIPT> 标签

javascript - 将句子中单词的首字母大写,手动替换除外

html - 如何让 CSS 滚动捕捉正常工作?

html - 我应该为图标使用 <i> 标签而不是 <span> 吗?

jquery - 如何以大字体显示下拉列表中选定的选项,而其他选项保持常规大小?

javascript - 使用 jQuery 将 Textarea 文本设置为格式正确的 HTML 代码

javascript - 如何正确堆叠砌体布局和延迟加载图像?