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.

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

When Not to Use

  • Outside of a list container — it is invalid HTML
  • For definition list content — use <dt> and <dd>

Basic Usage

In Unordered List

In Ordered List

Rich Content

List items can contain any flow content, not just text.

Nesting Lists

List items can contain nested lists to create hierarchical structures. The nested list must be inside the <li> element.

Value Attribute (Ordered Lists)

In ordered lists, use the value attribute to override the item's number. Subsequent items continue from that value.

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

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 (li + li) margin-block-start var(--size-xs)
In .inline / .unstyled lists margin-block-start 0
In [data-layout="grid"] margin-block-start 0

Attributes

Attribute Context Description
value Inside <ol> only Override the item's ordinal number

Related

  • <ul> — Unordered list container
  • <ol> — Ordered list container
  • <menu> — Semantic container for action buttons
  • <dl> — Definition list (uses <dt>/<dd> instead)
  • <nav> — Navigation container for menu lists