HTML 註釋語法極其簡單,但**規範使用**能大幅提升代碼可讀性與團隊協作效率。本文提供最精煉的語法速查與即用模板。
<!-- 註釋內容 -->
<!--
@file index.html
@project Project Name
@author Author Name <email@example.com>
@date 2024-01-15
@description 頁面描述
@license MIT
-->
<!-- === Header: 全站導航、Logo、搜索 === -->
<header id="site-header">...</header>
<!-- === Main: 內容區 === -->
<main id="main-content">...</main>
<!-- === Footer: 版權、備案、友鏈 === -->
<footer id="site-footer">...</footer>
<!--
Component: ProductCard
Props: { id, name, price, image, tag }
State: hover -> shadow-lg, click -> detail page
A11y: img[alt], price[aria-label]
TODO: Add skeleton loading
-->
<article class="product-card">...</article>
<!-- build:css assets/css/vendor.min.css -->
<link rel="stylesheet" href="lib/bootstrap.css">
<link rel="stylesheet" href="lib/fontawesome.css">
<!-- endbuild -->
<!-- DEBUG: 暫時隱藏側邊欄測試主內容寬度
<aside class="sidebar">...</aside>
-->
將這些模板存為代碼片,標準化團隊註釋風格,讓代碼自帶導航地圖。