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
This integer attribute indicates the current ordinal value of the list item as defined by the <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
This character attribute indicates the numbering type:
  • a : lowercase letters
  • A : uppercase letters
  • i : lowercase Roman numerals
  • I : uppercase Roman numerals
  • 1 : numbers
This type overrides the one used by its parent <ol> element, if any. 注意: This attribute has been deprecated; use the CSS list-style-type 特性代替。

范例

For more detailed examples, see the <ol> and <ul> 页面。

Ordered list

<ol>
    <li>first item</li>
    <li>second item</li>
    <li>third item</li>
</ol>
					

Ordered list with a custom value

<ol type="I">
    <li value="3">third item</li>
    <li>fourth item</li>
    <li>fifth item</li>
</ol>
					

Unordered list

<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.

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
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

图例

完整支持

完整支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

另请参阅

  • Other list-related HTML Elements: <ul> , <ol> , <menu> , and the obsolete <dir> ;
  • CSS properties that may be specially useful to style the <li> 元素:
    • the list-style property, to choose the way the ordinal is displayed,
    • CSS counters , to handle complex nested lists,
    • the margin property, to control the indent of the list item.

元数据

  • 最后修改: