是否可以嵌套 HTML 注释? [英] Are nested HTML comments possible?
本文介绍了是否可以嵌套 HTML 注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据标题;是否可以在有效的 HTML 中嵌套注释?看下面的例子...
as per the title; is it possible to have nested comments in valid HTML? see the example below...
<p>some text</p>
<!-- comment 1
<p>commented out html</p>
<!-- comment 2
// are nested html comment allowed?
end of comment 2 -->
<p>more commented out html</p>
end of comment 1 -->
<p>some more text</p>
似乎没有,有人知道我如何让嵌套评论起作用吗?
It appears not, does anybody know how I could get nested comments to work?
推荐答案
嵌套注释时,请将--"替换为- -".取消嵌套时,请反向执行此过程.被禁止的不是<!--
,而是--
.
When you nest a comment, replace "--" with "- -". When you un-nest, reverse the procedure. It's not the <!--
that is forbidden but the --
.
示例:
<!-- some stuff
<!- - some inner stuff - ->
<!- - a sibling - ->
the footer -->
这篇关于是否可以嵌套 HTML 注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文