Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

<li>

这篇翻译不完整。请帮忙从英语翻译这篇文章

HTML <li> 元素 (或者 HTML 列表条目元素) 用于表示列表里的条目。它必须被包含在一个父元素里:一个有顺序的列表(<ol>),一个无顺序的列表(<ul>),或者一个菜单 (<menu>)。在菜单或者无顺序的列表里,列表条目通常用点排列显示。在有顺序的列表里,列表条目通常是在左边有按升序排列计数的显示,例如数字或者字母。

Content categories None.
Permitted content Flow content.
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 parent elements An <ul>, <ol>, or <menu> element. Though not a conforming usage, the obsolete <dir> can also be a parent.
DOM interface HTMLLIElement
Element type Block

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.

Note: Prior to Gecko 9.0, negative values were incorrectly converted to 0. Starting in Gecko 9.0 all integer values are correctly parsed.

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.
Usage note: This attribute has been deprecated: use the CSS list-style-type property instead.

Examples

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

The above HTML will output:

  1. first item
  2. second item
  3. third item
<ol type="I">
    <li value="3">third item</li>
    <li>fourth item</li>
    <li>fifth item</li>
</ol>	

The above HTML will output:

  1. third item
  2. fourth item
  3. fifth item
<ul>
    <li>first item</li>
    <li>second item</li>
    <li>third item</li>
</ul>
  • first item
  • second item
  • third item

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

Specifications

Specification Status Comment
WHATWG HTML Living Standard
<li>
Living Standard  
HTML5
<li>
Recommendation  
HTML 4.01 Specification
<li>
Recommendation The type attribute has been deprecated.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 1.0 (1.7 or earlier) (Yes) (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 1.0 (1.0) (Yes) (Yes) (Yes)

See also

  • Other list-related HTML Elements: <ul>, <li>, <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.
 

文档标签和贡献者

 此页面的贡献者: JoshuaLee
 最后编辑者: JoshuaLee,