HTML/注释

维基教科书,自由的教学读本

HTML的注释内容应放在<!-- 与 -->之间。例如:

    <p>The first paragraph.</p>
    <!-- This comment spans one line, and will not be displayed to the browser. -->
    <p>The second paragraph.</p>
    <!--
       This comment spans multiple lines,
       and will also not be displayed to the browser.
    -->
    <p>The third paragraph.</p>

web浏览器彻底忽略注释。所以浏览器用户查看html源代码时也看不到注释。

应避免“嵌套注释”。这会给许多浏览器造成麻烦。

    <p>The second paragraph.</p>
    <!--
      <!--
       Nested comments should better be avoided.
        -->
    -->
    <p>The third paragraph.</p>