| 標籤 | 全稱 | 語意 | 預設標記 |
|---|---|---|---|
<ul> | Unordered List | 順序不重要的項目群 | 實心圓點 (disc) |
<ol> | Ordered List | 順序重要的項目群 | 十進位數字 (1.) |
<dl> | Description List | 術語-描述 配對 (名值對) | 無 (需 CSS 排版) |
<!-- 無序列表 -->
<ul>
<li>項目一</li>
<li>項目二</li>
</ul>
<!-- 有序列表 -->
<ol>
<li>步驟一</li>
<li>步驟二</li>
</ol>
<!-- 定義列表 -->
<dl>
<dt>HTML</dt>
<dd>超文本標記語言</dd>
<dt>CSS</dt>
<dd>層疊樣式表</dd>
</dl>
<ul>
<li>水果
<ul>
<li>蘋果</li>
<li>香蕉</li>
</ul>
</li>
<li>蔬菜
<ol>
<li>高麗菜</li>
<li>紅蘿蔔</li>
</ol>
</li>
</ul>
<li> 可直接包含 <ul>/<ol>,語意清晰。ul.custom { list-style: none; padding-left: 1.5em; }
ul.custom li::before {
content: "▸";
color: #007bff;
display: inline-block;
width: 1.5em;
margin-left: -1.5em;
}
/* 或使用 ::marker (現代瀏覽器) */
ul.custom li::marker { content: "▸ "; color: #007bff; }
ol.legal {
list-style: none;
counter-reset: section;
padding-left: 2em;
}
ol.legal li::before {
counter-increment: section;
content: counters(section, ".") " ";
font-weight: bold;
}
dl.glossary { display: grid; grid-template-columns: max-content 1fr; gap: 0.5em 1em; }
dl.glossary dt { font-weight: 600; grid-column: 1; }
dl.glossary dd { margin: 0; grid-column: 2; }
dl.glossary dt::after { content: ":"; }
<ol><ul><dl>選對列表語意,螢幕閱讀器能正確播報結構,CSS 控制更精準,維護者一眼明瞭。