Live Preview
A simple unordered list:
- HTML
- CSS
- JavaScript

By the end of this tutorial, you’ll build semantic lists with <li> inside <ul> and <ol>.
Wrap each list entry in <li> opening and closing tags.
Use bullets in ul and numbers in ol.
Place sub-lists inside an li for hierarchy.
Set custom numbering on ol list items.
Structure nav links as list items.
Style lists and keep markup semantic.
<li> Tag?The list item element (<li>) represents a single entry in an HTML list. It must be a direct or indirect child of a list container — typically <ul> (unordered) or <ol> (ordered) — and holds the text or content for one item.
Do not place bare <li> elements in the document body. Wrap them in ul, ol, or menu so browsers and assistive technology recognize the list structure.
Lists are one of the most common patterns on the web — feature lists, navigation menus, step-by-step instructions, and table-of-contents outlines all rely on <li>.
Place list content between opening and closing <li> tags inside a list parent:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul><li> must have a parent ul, ol, or menu.<li />) is not valid in HTML.li may contain flow content, including nested lists.ol when order matters; use ul when it does not.| Pattern | Code Snippet | Result |
|---|---|---|
| Unordered item | <ul><li>Apple</li></ul> |
|
| Ordered item | <ol><li>Step 1</li></ol> |
|
| Custom number | <li value="5"> in ol | Starts item at 5 |
| Nested list | <li>Parent<ul>...</ul></li> | Sub-items inside li |
| Nav link | <li><a href="...">Home</a></li> | Menu item pattern |
| ol start | <ol start="5"> | On ol, not li |
<li> in <ul> vs <ol>The parent list type determines how browsers render each li:
| Parent | Marker | Best for |
|---|---|---|
<ul> | Bullet (disc, circle, square) | Features, nav menus, unordered collections |
<ol> | Number (1, 2, 3…) | Steps, rankings, instructions |
value on li | Custom number in ol only | Resume numbering mid-list |
start on ol | First item number | Begin ordered list at 5, 10, etc. |
<li> vs <div>Use real list markup instead of divs with bullet characters:
| Approach | Markup | Notes |
|---|---|---|
| Semantic list | <ul><li>Item</li></ul> | Correct for lists |
| Div with bullet | <div>• Item</div> | Avoid — poor a11y |
| Screen readers | Announce list length and position | Only with ul/ol + li |
The <li> element supports one specific attribute plus global attributes:
value ol onlySets the ordinal value of this item in an ordered list. Following items continue from that number.
<li value="5">Item 5</li>class GlobalCSS hook for styling individual list items.
class="active"id GlobalUnique identifier for linking or scripting a specific item.
id="step-3"ol start On parentNot on li — use start on <ol> to begin numbering.
<ol start="5"><ol>
<li value="5">Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
</ol>Do not confuse value on li with start on ol. Both affect numbering but apply to different elements.
Ordered start values, unordered lists, nested items, navigation menus, and step-by-step instructions.
A simple unordered list:
Use start on <ol> or value on a specific <li> to control numbering.
<ol start="5">
<li>Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
</ol>Use <li> for feature lists, navigation menus, breadcrumbs, step instructions, outlines, and any grouped collection where each entry is a distinct list item.
Bullet-point lists with <ul> and <li>.
<ul>
<li>Item A</li>
<li>Item B</li>
<li>Item C</li>
</ul>Numbered lists with <ol> when sequence matters.
<ol>
<li>First Item</li>
<li>Second Item</li>
<li>Third Item</li>
</ol>Place a sub-list inside an li for hierarchical content.
<ul>
<li>Main Item 1
<ul>
<li>Subitem A</li>
<li>Subitem B</li>
</ul>
</li>
<li>Main Item 2</li>
</ul>Structure nav links as list items — often wrapped in <nav>.
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>Use ol and li for ordered instructions.
<ol>
<li>Open the application</li>
<li>Click on the "File" menu</li>
<li>Select "Save As"</li>
</ol>Style list items and their markers with CSS on the parent list or individual items:
list-style-type Bullets or numberslist-style-position Inside vs outside:last-child Style final itemlist-style: none Nav menu reset/* Custom list styling */
ul.features {
list-style-type: disc;
padding-left: 1.5rem;
}
ul.features li {
margin-bottom: 0.35rem;
line-height: 1.6;
}
nav ul {
list-style: none;
padding: 0;
display: flex;
gap: 1rem;
}Semantic lists help assistive technology convey structure:
Choose unordered or ordered list based on whether sequence matters.
Wrap every list entry in <li> tags.
Bullets for ul, numbers for ol.
Users and screen readers understand list length, order, and hierarchy.
The <li> element is fully supported in all browsers, including legacy Internet Explorer.
From legacy Internet Explorer to the latest mobile browsers — li inside ul and ol is fully supported.
Bottom line: Ship lists with confidence. The <li> element is safe to use in every production environment today.
The <li> tag is fundamental to structured HTML content. Whether you are building navigation, feature lists, or step-by-step guides, pairing li with the correct parent list creates semantic, accessible markup.
Remember to use ul for unordered items, ol when order matters, and nest sub-lists inside li for hierarchical outlines.
<li>ul for unordered and ol for ordered lists<nav>value on li only inside olli outside ul, ol, or menustart (on ol) with value (on li)ol when item order does not matter<li>Bookmark these before you ship — they’ll keep your lists semantic and accessible.
<li> is one entry in a list.
Must live inside ul, ol, or menu.
Bullets vs numbers — pick the right parent.
ComparisonSub-lists go inside an li.
Custom numbering for ordered items only.
AttributesWorks in every browser, including legacy IE.
Compatibilityul, ol, or menu.li must have a list parent. Bare list items in the body are invalid HTML.li inside ol, it sets the numeric marker for that item. It does not work on ul items.start is on ol and sets the first item’s number. value is on a specific li inside ol.ul or ol inside an li to create sub-lists.Try unordered, ordered, nested, and navigation lists in the interactive editor.
6 people found this page helpful