<ol>: 有序列表元素
<ol> HTML 元素表示專案的有序列表 - 通常呈現為編號列表。
試試
屬性
此元素還接受 全域性屬性.
reversed-
此布林屬性指定列表的專案按相反順序排列。專案將從高到低編號。
start-
一個整數,用於為列表專案開始計數。始終為阿拉伯數字(1、2、3 等),即使編號
type為字母或羅馬數字。例如,要從字母“d”或羅馬數字“iv”開始對元素進行編號,請使用start="4"。 type-
設定編號型別
a表示小寫字母A表示大寫字母i表示小寫羅馬數字I表示大寫羅馬數字1表示數字(預設值)
除非在封閉的
type屬性上使用了不同的<li>元素,否則指定的型別將用於整個列表。注意: 除非列表編號的型別很重要(例如法律或技術文件,其中專案按其編號/字母引用),否則請使用 CSS
list-style-type屬性。
使用說明
示例
簡單示例
html
<ol>
<li>Fee</li>
<li>Fi</li>
<li>Fo</li>
<li>Fum</li>
</ol>
結果
使用羅馬數字型別
html
<ol type="i">
<li>Introduction</li>
<li>List of Grievances</li>
<li>Conclusion</li>
</ol>
結果
使用start屬性
html
<p>Finishing places of contestants not in the winners' circle:</p>
<ol start="4">
<li>Speedwalk Stu</li>
<li>Saunterin' Sam</li>
<li>Slowpoke Rodriguez</li>
</ol>
結果
巢狀列表
html
<ol>
<li>first item</li>
<li>
second item
<!-- closing </li> tag is not here! -->
<ol>
<li>second item first subitem</li>
<li>second item second subitem</li>
<li>second item third subitem</li>
</ol>
</li>
<!-- Here's the closing </li> tag -->
<li>third item</li>
</ol>
結果
有序列表內嵌無序列表
html
<ol>
<li>first item</li>
<li>
second item
<!-- closing </li> tag is not here! -->
<ul>
<li>second item first subitem</li>
<li>second item second subitem</li>
<li>second item third subitem</li>
</ul>
</li>
<!-- Here's the closing </li> tag -->
<li>third item</li>
</ol>
結果
技術概述
規範
| 規範 |
|---|
| HTML 標準 # the-ol-element |
瀏覽器相容性
BCD 表格僅在瀏覽器中載入
另請參見
- 其他與列表相關的 HTML 元素:
<ul>、<li>、<menu> - 可能對樣式化
<ol>元素特別有用的 CSS 屬性list-style屬性,用於選擇序數的顯示方式- CSS 計數器,用於處理複雜的巢狀列表
line-height屬性,用於模擬已棄用的compact屬性margin屬性,用於控制列表縮排