References

Beginner-friendly references for web development, with live, editable examples.

The HTML <li> tag

Element All modern browsers Updated
Quick answer

The HTML <li> element represents a single list item. It must be a child of a <ul>, <ol> or <menu>, and can hold any content. Inside an ordered list, the value attribute can override its number.

Overview

The <li> (list item) element is a single entry in a list. It only makes sense as a direct child of a <ul>, an <ol> or a <menu> — but the item itself can contain almost anything: text, links, images, even nested lists.

In an ordered list, each item is numbered automatically. The value attribute sets a specific number for an item, and the items after it continue counting from there. In an unordered list, value has no effect.

Build hierarchy by nesting a complete <ul> or <ol> inside an <li> — that is how multi-level menus and outlines are structured.

Syntax

<ul>
  <li>A list item</li>
</ul>

Attributes

The <li> element supports the following attributes, in addition to the global attributes available to every HTML element.

Attribute Value Description
value A string or number, depending on the element and input type. Sets a control's value.

Example

Live example
<ol>
  <li>First</li>
  <li value="10">Jumps to ten</li>
  <li>Then eleven</li>
</ol>

More Examples

Best practices

  • Use <li> only as a direct child of a <ul>, <ol> or <menu>.
  • Nest a full list inside an <li> to create sub-lists and outlines.
  • Use the value attribute to set a specific number in an ordered list.
  • Do not place an <li> outside a list — it has no meaning there.

Frequently asked questions

What is the li element?
A single item within a <ul>, <ol> or <menu> list.
What can go inside an li?
Almost anything — text, links, images and even nested lists for hierarchy.
How do I set a specific number on a list item?
Use the value attribute in an ordered list; subsequent items continue from that number.
Can I use li outside a list?
No. An <li> only has meaning inside a <ul>, <ol> or <menu>.