跳至內容

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>