Li

<li>: The List Item element #

::: section-content The <li> HTML 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. :::

Try it #

::: section-content ::: iframe ::: {.output-header .border-rounded-top}

HTML Demo: <li> #

Reset :::

::: {#warning-no-script .warning-container} ::: warning The interactive example cannot be shown because JavaScript is disabled. ::: :::

::: {#warning-mathml-not-supported .warning-container .hidden} ::: warning The interactive example cannot be shown because MathML is not supported by your browser. ::: :::

::: {#editor-container .editor-container .tabbed-shorter .hidden .border-rounded-bottom editor-type=“tabbed”} ::: {#tab-container .section .tabs} ::: {#tablist .tab-list role=“tablist”} HTML

CSS

JavaScript :::

::: {#html-panel .section .hidden tabindex=“0” role=“tabpanel” aria-labelledby=“html” aria-hidden=“true”} ::: {#html-editor}

Apollo astronauts:

<ul>
  <li>Neil Armstrong</li>
  <li>Alan Bean</li>
  <li>Peter Conrad</li>
  <li>Edgar Mitchell</li>
  <li>Alan Shepard</li>
</ul>

::: :::

::: {#css-panel .section .hidden tabindex=“0” role=“tabpanel” aria-labelledby=“css” aria-hidden=“true”} ::: {#css-editor} p, li { font: 1rem ‘Fira Sans’, sans-serif; }

p {
  font-weight: bold;
}

::: :::

::: {#js-panel .section .hidden tabindex=“0” role=“tabpanel” aria-labelledby=“js” aria-hidden=“true”} ::: {#js-editor} ::: ::: :::

::: {#output .output-container}

Output #

::: :::

::: {.section .console-container .hidden aria-hidden=“true”}

Console Output #

![] clear console

::: {#console .console} ::: :::

::: {#html-output .output .editor-tabbed} %html-content% ::: ::: :::

Attributes #

::: section-content 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>).

type [Deprecated]{.visually-hidden} [Non-standard]{.visually-hidden}

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.

::: {#sect1 .notecard .note} Note: This attribute has been deprecated; use the CSS list-style-type property instead. ::: :::

Examples #

::: section-content For more detailed examples, see the <ol> and <ul> pages. :::

Ordered list #

::: section-content ::: code-example [html]{.language-name}

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

:::

Result #

::: {#sect2 .code-example} ::: iframe ::: ::: :::

Ordered list with a custom value #

::: section-content ::: code-example [html]{.language-name}

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

:::

Result #

::: {#sect3 .code-example} ::: iframe ::: ::: :::

Unordered list #

::: section-content ::: code-example [html]{.language-name}

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

:::

Result #

::: {#sect4 .code-example} ::: iframe ::: ::: :::

Technical summary #

::: section-content

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

Specifications #

::: _table #

Specification #

HTML Standard
[# the-li-element]{.small}


:::

Browser compatibility #

::: _table Desktop Mobile


        Chrome    Edge   Firefox   Internet Explorer   Opera   Safari   WebView Android   Chrome Android   Firefox for Android   Opera Android   Safari on IOS   Samsung Internet

li 1 12 1 5.5 ≤12.1 3 4.4 18 4 ≤12.1 1 1.0 type 1 12 1 ≤6 ≤12.1 ≤4 4.4 18 4 ≤12.1 ≤3.2 1.0 value 1 12 1 ≤6 ≤12.1 ≤4 4.4 18 4 ≤12.1 ≤3.2 1.0 :::

See also #

::: section-content

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

::: _attribution © 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/li{._attribution-link} :::