HTML
<li>
element
用于表示列表中的项。
It must be contained in a parent element: an ordered list (
<ol>
), an unordered list (
<ul>
), or a menu (
<menu>
). In menus and unordered lists, list items are usually displayed using bullet points. In ordered lists, they are usually displayed with an ascending counter on the left, such as a number or letter.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
| 内容类别 | None. |
|---|---|
| 准许内容 | 流内容 . |
| Tag omission |
The end tag can be omitted if the list item is immediately followed by another
<li>
element, or if there is no more content in its parent element.
|
| Permitted parents |
An
<ul>
,
<ol>
,或
<menu>
element. Though not a conforming usage, the obsolete
<dir>
can also be a parent.
|
| Implicit ARIA role |
listitem
when child of an
ol
,
ul
or
menu
|
| Permitted ARIA roles |
menuitem
,
menuitemcheckbox
,
menuitemradio
,
option
,
none
,
presentation
,
radio
,
separator
,
tab
,
treeitem
|
| DOM 接口 |
HTMLLIElement
|
此元素包括 全局属性 .
value
<ol>
element. The only allowed value for this attribute is a number, even if the list is displayed with Roman numerals or letters. List items that follow this one continue numbering from the value set. The
值
attribute has no meaning for unordered lists (
<ul>
) or for menus (
<menu>
).
注意
: This attribute was deprecated in HTML4, but reintroduced in HTML5.
type
a
: lowercase letters
A
: uppercase letters
i
: lowercase Roman numerals
I
: uppercase Roman numerals
1
: numbers
<ol>
element, if any.
注意:
This attribute has been deprecated; use the CSS
list-style-type
特性代替。
For more detailed examples, see the
<ol>
and
<ul>
页面。
<ol>
<li>first item</li>
<li>second item</li>
<li>third item</li>
</ol>
<ol type="I">
<li value="3">third item</li>
<li>fourth item</li>
<li>fifth item</li>
</ol>
<ul>
<li>first item</li>
<li>second item</li>
<li>third item</li>
</ul>
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of '<li>' in that specification. |
实时标准 | |
|
HTML5
The definition of '<li>' in that specification. |
推荐 | |
|
HTML 4.01 Specification
The definition of '<li>' in that specification. |
推荐 |
type
attribute has been deprecated.
|
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
li
|
Chrome 完整支持 Yes | Edge 完整支持 12 | Firefox 完整支持 1 | IE 完整支持 Yes | Opera 完整支持 Yes | Safari 完整支持 Yes | WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 4 | Opera Android 完整支持 Yes | Safari iOS 完整支持 Yes | Samsung Internet Android 完整支持 Yes |
type
弃用
非标
|
Chrome 完整支持 Yes | Edge 完整支持 12 | Firefox 完整支持 1 | IE 完整支持 Yes | Opera 完整支持 Yes | Safari 完整支持 Yes | WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 4 | Opera Android 完整支持 Yes | Safari iOS 完整支持 Yes | Samsung Internet Android 完整支持 Yes |
value
|
Chrome 完整支持 Yes | Edge 完整支持 12 | Firefox 完整支持 1 | IE 完整支持 Yes | Opera 完整支持 Yes | Safari 完整支持 Yes | WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 4 | Opera Android 完整支持 Yes | Safari iOS 完整支持 Yes | Samsung Internet Android 完整支持 Yes |
完整支持
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
<ul>
,
<ol>
,
<menu>
, and the obsolete
<dir>
;
<li>
元素:
list-style
property, to choose the way the ordinal is displayed,
margin
property, to control the indent of the list item.