li
The list item element represents an individual item within a list structure.
Description
The <li> element represents a single item in a list. It must be a direct child of an <ul> (unordered list), <ol> (ordered list), or <menu> element.
List items can contain any flow content, including text, links, images, and nested lists.
Semantic Meaning
A list item conveys that:
- The content is one piece of a larger collection
- It is related to its sibling items
- In ordered lists, it has a specific position in a sequence
- In unordered lists, it is one of several equal items
Screen readers announce "list item" along with the item's position (e.g., "1 of 5") to help users navigate list content.
When to Use
- As a direct child of
<ul>,<ol>, or<menu> - To wrap individual items in any list structure
- For navigation menu items (inside
<nav>with<ul>) - For any grouped content that belongs in a list
When Not to Use
Basic Usage
In Unordered List
- Simple text item
- Another text item
- Third text item
In Ordered List
- First step
- Second step
- Third step
Rich Content
List items can contain any flow content, not just text.
Links
Multiple Elements
-
Feature Name
Description of the feature with supporting text.
-
Another Feature
More descriptive text about this feature.
Images
Nesting Lists
List items can contain nested lists to create hierarchical structures. The nested list must be inside the <li> element.
- Parent item one
- Child item one
- Child item two
- Grandchild item
- Parent item two
Mixed List Types
You can nest different list types within each other.
- Step one: gather materials
- Paper
- Scissors
- Glue
- Step two: cut the paper
- Step three: assemble
Value Attribute (Ordered Lists)
In ordered lists, use the value attribute to override the item's number. Subsequent items continue from that value.
- Regular item (1)
- Jumps to 10
- Continues at 11
- Jumps to 20
- Continues at 21
Note: The value attribute only applies to <li> elements within <ol>. It has no effect in <ul>.
Accessibility
Screen Reader Behavior
- Announced as "list item" with position (e.g., "bullet, list item 2 of 5")
- In ordered lists, the number is announced
- Nested list items announce their depth level
- Users can navigate between items with keyboard shortcuts
Best Practices
- Always place
<li>inside a proper list container - Keep list items focused on single concepts
- Use meaningful content - avoid empty list items
- Limit nesting depth to 3 levels for usability
- For complex content, consider headings within items
Common Mistakes
- Wrong: Using
<li>outside a list container - Wrong: Placing block elements directly between
<ul>/<ol>and<li> - Wrong: Empty list items for spacing
CSS Properties
| Context | Property | Value |
|---|---|---|
| Adjacent items | margin-block-start |
var(--size-xs) |
In .inline lists |
margin-block-start |
0 |
In .unstyled lists |
margin-block-start |
0 |
The li + li selector adds vertical spacing between consecutive items, creating comfortable reading rhythm.
Attributes
| Attribute | Context | Description |
|---|---|---|
value |
Inside <ol> only |
Override the item's ordinal number |