©
Dieses Dokument verwendetPHP-Handbuch für chinesische WebsitesFreigeben
HTML元素代表项目,通常呈现为编号列表的有序列表。
|
内容类别 |
Flow content, and if the
|
|---|---|
|
允许的内容 |
一个或多个 |
|
标签省略 |
不允许,开始标签和结束标签都不能省略。 |
|
允许的父元素 |
Any element that accepts flow content. |
|
允许的 ARIA 角色 |
directory, group, listbox, menu, menubar, radiogroup, tablist, toolbar, tree, presentation |
|
DOM 接口 |
HTMLOListElement |
这个元素包含全局属性。
compact这个布尔属性暗示列表应该以紧凑的风格呈现。该属性的解释取决于用户代理,并且不适用于所有浏览器。
注:不要使用这个属性,这个属性已经过时:元素的样式应当使用CSS 来控制,想要获得和这个属性相似的效果,使用 CSS 属性line-height并设置值为80%。
reversedHTML5 这个布尔属性规定了列表的条目采用倒序,即最不重要的条目放在列表第一个位置。
startHTML5 这是整数属性,规定了列表得条目序号的开始的值。尽管列表条目的序号可能是罗马字母顺序,如 XXXI, 或者字母,这个开始的顺序总是使用数字表示。比如想要元素序号从字母 “C” 开始,使用。
注:这个属性在 HTML4 中弃用,但是在 HTML5 中被重新引入。
type指示编号类型:
'a'表示小写字母编号,
'A'表示大写字母编号,
'i'表示小写罗马数字编号,
'I'表示大写罗马数字编号,
'1'表示数字编号(默认值)。
这个类型集用于整个列表,除非type在封闭元素中使用了不同的属性。
注意:此属性在 HTML4 中已被弃用,但在 HTML5 中重新引入。除非清单号码的价值很重要(例如,在法律或技术文件中的项目将通过其号码/字母引用),则list-style-type应该使用 CSS 属性。
通常,有序列表条目和它前面的编号一起显示,它的编号可以是任何形式,如数字、字母或者罗马数字,甚至可以是小子弹。而这种样式(小子弹)并没有在 HTML 页面内定义,而是在其关联的 CSS 中,使用了list-style-type属性。
HTML 并没有对和元素的深度和反复使用次数(overlap)作出限制。
和都是列表项。它们的不同点在于元素里条目的顺序是有意义的。 对于该选择哪一个去使用下面有个建议:尝试去更改列表项的顺序,如果其含义改变了,那么应该使用元素,否则使用更合适。
- first item
- second item
- third item
在 HTML 上方输出:
first item
second item
third item
- foo
- bar
- spam
上面的 HTML 将输出
i. foo
ii. bar
iii. spam
start属性
- first item
- second item
- third item
在 HTML 上方输出:
first item
second item
third item
- first item
- second item
- second item first subitem
- second item second subitem
- second item third subitem
- third item
在 HTML 上方输出:
first item
second item
second item first subitem
second item second subitem
second item third subitem
third item
- first item
- second item
- second item first subitem
- second item second subitem
- second item third subitem
- third item
在 HTML 上方输出:
first item
second item
second item first subitem
second item second subitem
second item third subitem
third item
|
Specification |
Status |
Comment |
|---|---|---|
|
HTML Living StandardThe definition of '
|
Living Standard |
No change since last W3C snapshot, HTML5. |
|
HTML5The definition of 'HTMLOListElement' in that specification. |
Recommendation |
Added reversed and start attributed; un-deprecated type |
|
HTML 4.01 SpecificationThe definition of '
|
Recommendation |
Deprecated compact and type. |
|
Feature |
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
|---|---|---|---|---|---|---|
|
Basic Support |
(Yes) |
(Yes) |
1 |
(Yes) |
(Yes) |
(Yes) |
|
compact |
(Yes) |
(Yes) |
1 |
(Yes) |
(Yes) |
(Yes) |
|
reversed |
18 |
? |
18 |
No |
(Yes) |
5.2 |
|
start |
(Yes) |
(Yes) |
1 |
(Yes) |
(Yes) |
(Yes) |
|
type |
(Yes) |
(Yes) |
1 |
(Yes) |
(Yes) |
(Yes) |
|
Feature |
Android |
Chrome for Android |
Edge mobile |
Firefox for Android |
IE mobile |
Opera Android |
iOS Safari |
|---|---|---|---|---|---|---|---|
|
Basic Support |
(Yes) |
(Yes) |
(Yes) |
1 |
(Yes) |
(Yes) |
(Yes) |
|
compact |
(Yes) |
(Yes) |
(Yes) |
1 |
(Yes) |
(Yes) |
(Yes) |
|
reversed |
(Yes) |
(Yes) |
? |
18 |
No |
(Yes) |
(Yes) |
|
start |
(Yes) |
(Yes) |
(Yes) |
1 |
(Yes) |
(Yes) |
(Yes) |
|
type |
(Yes) |
(Yes) |
(Yes) |
1 |
(Yes) |
(Yes) |
(Yes) |