HTML Reference ยท Text Content
The <li> element
Reference for the HTML <li> element: list items in <ul>, <ol> and <menu>, the value attribute for numbering, nesting lists, tag omission and technical details.
The <li> element is a list item. It lives inside an unordered list (<ul>), an ordered list (<ol>) or a <menu>, and can contain anything from a word to paragraphs, images and nested lists.
<ul> <li>Flour</li> <li>Water</li> </ul>
Try it
The nested list sits inside the "Fruit" item. In the ordered list, value="5" jumps the counter, so the item after it becomes 6.
Attributes
| Attribute | Values | Description |
|---|---|---|
value |
An integer (can be negative) | The ordinal number of this item. Only valid when the parent is an <ol>; following items continue counting from it. |
It also accepts the global attributes. The old type attribute on <li> is obsolete; use the CSS list-style-type property.
Usage notes
- Only inside lists. An
<li>must be a direct child of<ul>,<ol>or<menu>. Text or other elements placed directly in a list, outside an<li>, are invalid. - Nest lists inside items. A sub-list goes inside the
<li>it belongs to, not between two<li>elements. - Markers come from CSS.
<li>usesdisplay: list-item, which draws the bullet or number. Change markers withlist-style-typeor the::markerpseudo-element. - Optional end tag. The parser closes an
<li>when the next<li>starts or the list ends. Writing</li>is still recommended for readability. - Accessibility. Screen readers announce list items with their position, such as "item 2 of 5". Removing markers with
list-style: nonecan make some browsers stop exposing the list; addrole="list"to the parent if that matters.
Technical summary
| Content categories | None |
| Permitted content | Flow content |
| Tag omission | Start tag required. The end tag may be omitted if the element is immediately followed by another <li>, or if there is no more content in the parent element |
| Permitted parents | <ul>, <ol> or <menu> |
| Implicit ARIA role | listitem |
| DOM interface | HTMLLIElement |
| Default display | list-item |
Browser support
Supported in every browser.
Related
<ul>โ unordered lists<ol>โ ordered lists<menu>โ lists of commands- Lesson: Lists
- Lesson: Ordered List Options
- Lesson: Nested Lists