<!-- 單行註釋 -->
<!--
多行註釋
可跨越多行
-->
<!-- <!-- 內層 --> 外層 --> 會在第一個 --> 結束。-- (除開頭結尾),否則解析錯誤。<!--[if IE]>
<link rel="stylesheet" href="ie-fix.css">
<![endif]-->
<!--[if gt IE 8]><!-->
<link rel="stylesheet" href="modern.css">
<!--<![endif]-->
IE10+ 已移除支援,現代專案不再需要。
<!-- build:css css/main.min.css -->
<link rel="stylesheet" href="css/a.css">
<link rel="stylesheet" href="css/b.css">
<!-- endbuild -->
<!-- @include partials/header.html -->
<!-- webpackChunkName: "lazy-module" -->
Grunt/Gulp/Webpack/Vite 等構建工具解析特定註釋執行合併、壓縮、代碼分割。
<!-- 區塊語意說明:主要導航區 -->
<nav aria-label="主導航">...</nav>
<!-- 圖片替代文字說明:裝飾性圖片 alt="" -->
<img src="decoration.svg" alt="" role="presentation">
<!-- 結構標記:方便開發者快速定位 -->
<!-- /HEADER -->
<!-- MAIN CONTENT -->
<!-- FOOTER -->
| 語言 | 單行 | 多行 |
|---|---|---|
| HTML | <!-- --> | <!-- --> |
| CSS | /* */ | /* */ |
| JavaScript | // | /* */ |
善用註釋標記區塊邊界、說明業務邏輯、配合構建工具,讓團隊協作更高效。