标准模式HTML在注释中禁止双连字符。
<!-- This is a perfectly valid comment - I think. -->
<!-- Invalid comment -- definitely. -->
有三个额外的限制,这些无效的示例是例证:
<!--> invalid -->
<!---> invalid -->
<!-- invalid --->
为什么要指定所有这些小的边缘情况?特别是为什么要禁止使用双连字符?
标准模式HTML在注释中禁止双连字符。
<!-- This is a perfectly valid comment - I think. -->
<!-- Invalid comment -- definitely. -->
有三个额外的限制,这些无效的示例是例证:
<!--> invalid -->
<!---> invalid -->
<!-- invalid --->
为什么要指定所有这些小的边缘情况?特别是为什么要禁止使用双连字符?
[定义:注释可以出现在文档中其他标记之外的任何位置;此外,它们可以出现在文档类型声明中语法允许的位置。它们不是文档的字符数据;XML处理器可以但不必使应用程序能够检索注释文本。为了兼容性,在注释中不得出现字符串“--”(双破折号)。]参数实体引用不能在注释中被识别。
该语法不允许以"--->"结束的注释。
看起来,这是XML的一个特性,仅仅是为了确保XML与SGML兼容。http://www.w3.org/TR/REC-xml/#sec-comments
<!-- valid html comment -- >
。 - Cheery<html><body><p>This is a test...<!-- Invalid comment -- definitely. -->of the emergency broadcast system.</p></body></html>
呈现为*This is a test...of the emergency broadcast system.*,并且显示效果良好。 - J0e3gan