<ol>: The Ordered List element
<ol> HTML 元素表示项目的有序列表 - 通常呈现为编号列表。
¥The <ol> HTML element represents an ordered list of items — typically rendered as a numbered list.
Try it
属性
¥Attributes
该元素还接受 全局属性。
¥This element also accepts the global attributes.
- reversed
- 
    此布尔属性指定列表的项目按相反顺序排列。项目将从高到低编号。 
- start
- 
    列表项开始计数的整数。始终为阿拉伯数字(1、2、3 等),即使编号 type是字母或罗马数字。例如,要从字母 "d" 或罗马数字 "四、" 开始对元素进行编号,请使用start="4"。
- type
- 
    设置编号类型: - a为小写字母
- A代表大写字母
- i表示小写罗马数字
- I表示大写罗马数字
- 1代表数字(默认)
 除非在封闭的 <li>元素上使用不同的type属性,否则指定的类型将用于整个列表。注意:除非列表编号的类型很重要(例如法律或技术文档,其中项目通过其编号/字母引用),否则请使用 CSS list-style-type属性。¥Note: Unless the type of the list number matters (like legal or technical documents where items are referenced by their number/letter), use the CSS list-style-typeproperty instead.
使用说明
¥Usage notes
通常,有序列表项显示时带有前面的 marker,例如数字或字母。
¥Typically, ordered list items display with a preceding marker, such as a number or letter.
<ol> 和 <ul>(或同义词 <menu>)元件可以根据需要嵌套得深,根据需要在 <ol>、<ul>(或 <menu>)之间交替。
¥The <ol> and <ul> (or the synonym <menu>) elements may nest as deeply as desired, alternating between <ol>, <ul> (or <menu>) as needed.
<ol> 和 <ul> 元素均表示项目列表。与 <ol> 元素不同的是,顺序是有意义的。例如:
¥The <ol> and <ul> elements both represent a list of items. The difference is with the <ol> element, the order is meaningful. For example:
- 秘诀中的步骤
- 路线导航
- 营养成分表上所占比例递减的成分表
要确定使用哪个列表,请尝试更改列表项的顺序;如果含义发生变化,请使用 <ol> 元素,否则你可以使用 <ul>,或者如果你的列表是菜单,则可以使用 <menu>。
¥To determine which list to use, try changing the order of the list items; if the meaning changes, use the <ol> element — otherwise you can use <ul> otherwise, or <menu> if your list is a menu.
示例
简单的例子
使用罗马数字类型
使用开始属性
嵌套列表
有序列表内的无序列表
¥Unordered list inside ordered list
<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>
结果
¥Result
技术总结
¥Technical summary
规范
| Specification | 
|---|
| HTML Standard # the-ol-element | 
浏览器兼容性
BCD tables only load in the browser
也可以看看
¥See also
- 其他与列表相关的 HTML 元素:<ul>,<li>,<menu>
- 对于 <ol>元素的样式可能特别有用的 CSS 属性:- list-style属性,用于选择序数的显示方式
- CSS 计数器,处理复杂的嵌套列表
- line-height属性,模拟已弃用的- compact属性
- margin属性,控制列表缩进