关于 HTML 页面内的评论:
例如:
<html>
<head></head>
<body>
<!--
<p><font size="4">--</font></p>
-->
</body>
</html>
使用 http://validator.w3.org/check ,我收到以下错误消息。有道理吗?
Line 6, Column 21: invalid comment declaration: found character "<" outside comment but inside comment declaration
<p><font size="4">--</font></p>
Check that you are using a proper syntax for your comments, e.g: . This error may appear if you forget the last "--" to close one comment, and later open another.
最佳答案
是的,这是有道理的。
要理解错误消息,您必须理解注释标记。它由三个关键部分组成,<!
启动标签,--
开始和结束评论,以及 >
结束标记。
当你输入 --
在评论的文本中,您实际上结束了评论部分。直到标签末尾的其余文本都是无效的,因为它不是评论,您只能在评论标签内添加评论。
标签中也可以有多个评论:
<!-- comment -- -- another comment -->
关于html - 为什么 HTML 验证器给我关于此 HTML 注释的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3320350/