跳至內容

超文字標記語言/註釋

來自維基百科,一個開放世界的開放書籍

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>

與辦公軟體中的註釋不同,註釋被瀏覽器完全忽略,因此頁面讀者不會知道它們的存在。不過,它們可以在網頁的原始檔中檢視。

應避免使用巢狀註釋,因為這可能會給許多瀏覽器帶來麻煩。一個示例:

    <p>The second paragraph.</p>
    <!--
      <!--
       Nested comments should better be avoided.
        -->
    -->
    <p>The third paragraph.</p>
華夏公益教科書