在HTML5中使用null实体(例如�)是否有效? [英] Is the use of the null entity (e.g �) valid in HTML5?
问题描述
我认为 null实体(�
)在XML中正式无效。但我在处理HTML时遇到过它。 (也许代表一种零宽度字符?)但它是否有效标记并且浏览器会不会出现?
I believe the null entity (�
) is officially invalid in XML. But I have encountered it when processing HTML. (Perhaps to represent a kind of zero-width character?) But is it valid markup and will browsers freak out?
推荐答案
否,它不是有效的HTML5。您可以通过 W3C 验证器运行以下片段来轻松查看:
No, it's not valid HTML5. You can easily see this by running the following fragment through a validator such as W3C's:
<!DOCTYPE html><title>�</title>
这将导致以下错误:
第1行,第27列:字符引用扩展为零。
Line 1, Column 27: Character reference expands to zero.
特定的代码点是规范中列出了不合法的字符引用( W3C HTML5 , WHATWG HTML Living Standard ):
The specific code points that are not legal in character references are listed in the spec (W3C HTML5, WHATWG HTML Living Standard):
上述数字字符引用形式允许引用U + 0000,U + 000D以外的任何Unicode代码点,永久未定义的Unicode字符(非字符),代理(U + D800-U + DFFF)和空格字符以外的控制字符。
The numeric character reference forms described above are allowed to reference any Unicode code point other than U+0000, U+000D, permanently undefined Unicode characters (noncharacters), surrogates (U+D800–U+DFFF), and control characters other than space characters.
这篇关于在HTML5中使用null实体(例如&#x0;)是否有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!