<!-- 註釋開始:<! + -- (驚嘆號+雙連字號)
註釋內容
--> 註釋結束:-- + > (雙連字號+大於號)
<!-- 頁首區塊 -->
<header>...</header>
<!--
多行說明:
1. 此區塊為共用元件
2. 修改時同步更新 footer
-->
<footer>...</footer>
<!-- 外層
<!-- 內層 --> ← 這裡就會被視為結束
外層剩餘文字 --> ← 這段會直接顯示在頁面上!
解決方案:若需暫存大區塊,改用版本控制或編輯器摺疊,不要巢狀註釋。
| 編輯器 | 切換註釋快捷鍵 | 自訂片段建議 |
|---|---|---|
| VS Code | Ctrl+/ / Cmd+/ | hc → <!-- $1 --> |
| WebStorm/PhpStorm | Ctrl+/ / Cmd+/ | Live Template: hcom |
| Sublime Text | Ctrl+/ | Snippet: <!-- $1 --> |
| Vim/Neovim | gcc (需 commentary.vim) | UltiSnips 定義 |
// vite.config.js / rollup.config.js
import htmlMinifier from 'rollup-plugin-html-minifier';
export default {
plugins: [
htmlMinifier({
removeComments: true, // 移除所有註釋
collapseWhitespace: true, // 壓縮空白
minifyCSS: true,
minifyJS: true
})
]
};
<!--[if IE]> <link rel="stylesheet" href="ie.css"> <![endif]-->
<!--[if gt IE 8]><!--> <link rel="stylesheet" href="modern.css"> <!--<![endif]-->
現代專案(支援 IE11+)已無需使用,保留認知即可。