在 HTML 个评论标签中放置 HTML 个评论标签
Placing HTML comment tags within HTML comment tags
所以,这可能是一个非常具体的用例,但我们开始吧。
我正在帮助一家公司发送一段 HTML 代码给我们一群人,我们将从 excel sheet 中获取数据,并且将它放在 HTML 中的适当位置以填充 table。我正在努力帮助清理它,以便它对那些不真正正常编码的人有意义,因为只要他们知道将数据放在哪里,他们就不需要理解代码。我打算在文档的顶部放置一个注释块,其中包含一些注释,其中之一将讨论 <!-- and -->
标签。我担心的是,由于该注释将嵌套在注释标记中,注释中的 --> 标记是否会关闭注释,并导致注释的其余部分被读取为代码?下面的示例代码行。
<!--Begin instructions for editing. Make sure you change the information between the <td></td> tags, and not the <!-- --> tags. End instructions for editing.-->
有没有办法让它成为 HTML 中的有效评论,并且直到第二个 --> 标签才关闭评论?
没有。参见 the specification。
Comments must have the following format:
- The string "
<!--
".
- Optionally, text, with the additional restriction that the text must not start with the string "
>
", nor start with the string
"->
", nor contain the strings "<!--
", "-->
", or "--!>
",
nor end with the string "<!-
".
- The string "
-->
".
一旦评论部分得到 --> 它将终止评论。
因此,您需要将 --> 替换为任何其他内容,例如~~> 等...
您的代码可以是:
<!--Begin instructions for editing. Make sure you change the information between the <td></td> tags, and not the <!~~ ~~> tags. End instructions for editing.-->
所以,这可能是一个非常具体的用例,但我们开始吧。
我正在帮助一家公司发送一段 HTML 代码给我们一群人,我们将从 excel sheet 中获取数据,并且将它放在 HTML 中的适当位置以填充 table。我正在努力帮助清理它,以便它对那些不真正正常编码的人有意义,因为只要他们知道将数据放在哪里,他们就不需要理解代码。我打算在文档的顶部放置一个注释块,其中包含一些注释,其中之一将讨论 <!-- and -->
标签。我担心的是,由于该注释将嵌套在注释标记中,注释中的 --> 标记是否会关闭注释,并导致注释的其余部分被读取为代码?下面的示例代码行。
<!--Begin instructions for editing. Make sure you change the information between the <td></td> tags, and not the <!-- --> tags. End instructions for editing.-->
有没有办法让它成为 HTML 中的有效评论,并且直到第二个 --> 标签才关闭评论?
没有。参见 the specification。
Comments must have the following format:
- The string "
<!--
".- Optionally, text, with the additional restriction that the text must not start with the string "
>
", nor start with the string "->
", nor contain the strings "<!--
", "-->
", or "--!>
", nor end with the string "<!-
".- The string "
-->
".
一旦评论部分得到 --> 它将终止评论。
因此,您需要将 --> 替换为任何其他内容,例如~~> 等...
您的代码可以是:
<!--Begin instructions for editing. Make sure you change the information between the <td></td> tags, and not the <!~~ ~~> tags. End instructions for editing.-->