<li> - HTML: HyperText Markup Language 编辑

The HTML <li> element is used to represent an item in a list. 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.

Content categoriesNone.
Permitted contentFlow content.
Tag omissionThe 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 parentsAn <ul>, <ol>, or <menu> element. Though not a conforming usage, the obsolete <dir> can also be a parent.
Implicit ARIA rolelistitem when child of an ol, ul or menu
Permitted ARIA rolesmenuitem, menuitemcheckbox, menuitemradio, option, none, presentation, radio, separator, tab, treeitem
DOM interfaceHTMLLIElement

Attributes

This element includes the global attributes.

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 value attribute has no meaning for unordered lists (<ul>) or for menus (<menu>). Note: This attribute was deprecated in HTML4, but reintroduced in HTML5.
type This deprecated API should no longer be used, but will probably still work.
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. Note: This attribute has been deprecated; use the CSS list-style-type property instead.

Examples

For more detailed examples, see the <ol> and <ul> pages.

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>

Specifications

SpecificationStatusComment
HTML Living Standard
The definition of '<li>' in that specification.
Living Standard
HTML5
The definition of '<li>' in that specification.
Recommendation
HTML 4.01 Specification
The definition of '<li>' in that specification.
RecommendationThe type attribute has been deprecated.

Browser compatibility

BCD tables only load in the browser

See also

  • Other list-related HTML Elements: <ul>, <ol>, <menu>, and the obsolete <dir>;
  • CSS properties that may be specially useful to style the <li> element:
    • 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:105 次

字数:11017

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文