HTML <li> Tag

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 6 Examples
Lists & Navigation

What You’ll Learn

By the end of this tutorial, you’ll build semantic lists with <li> inside <ul> and <ol>.

01

Core Syntax

Wrap each list entry in <li> opening and closing tags.

02

ul vs ol

Use bullets in ul and numbers in ol.

03

Nested Lists

Place sub-lists inside an li for hierarchy.

04

value Attribute

Set custom numbering on ol list items.

05

Navigation Menus

Structure nav links as list items.

06

CSS & Accessibility

Style lists and keep markup semantic.

What Is the <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.

💡
Always inside a list parent

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

📝 Syntax

Place list content between opening and closing <li> tags inside a list parent:

syntax-ul.html
<ul>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>

Syntax Rules

  • <li> must have a parent ul, ol, or menu.
  • Self-closing syntax (<li />) is not valid in HTML.
  • An li may contain flow content, including nested lists.
  • Use ol when order matters; use ul when it does not.

⚡ Quick Reference

PatternCode SnippetResult
Unordered item<ul><li>Apple</li></ul>
  • Apple
Ordered item<ol><li>Step 1</li></ol>
  1. Step 1
Custom number<li value="5"> in olStarts 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:

ParentMarkerBest for
<ul>Bullet (disc, circle, square)Features, nav menus, unordered collections
<ol>Number (1, 2, 3…)Steps, rankings, instructions
value on liCustom number in ol onlyResume numbering mid-list
start on olFirst item numberBegin ordered list at 5, 10, etc.

⚖️ Semantic <li> vs <div>

Use real list markup instead of divs with bullet characters:

ApproachMarkupNotes
Semantic list<ul><li>Item</li></ul>Correct for lists
Div with bullet<div>&bull; Item</div>Avoid — poor a11y
Screen readersAnnounce list length and positionOnly with ul/ol + li

🧰 Attributes

The <li> element supports one specific attribute plus global attributes:

value ol only

Sets the ordinal value of this item in an ordered list. Following items continue from that number.

<li value="5">Item 5</li>
class Global

CSS hook for styling individual list items.

class="active"
id Global

Unique identifier for linking or scripting a specific item.

id="step-3"
ol start On parent

Not on li — use start on <ol> to begin numbering.

<ol start="5">
value-attribute.html
<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.

Examples Gallery

Ordered start values, unordered lists, nested items, navigation menus, and step-by-step instructions.

Live Preview

A simple unordered list:

  • HTML
  • CSS
  • JavaScript

Ordered List Starting at 5

Use start on <ol> or value on a specific <li> to control numbering.

ol-start.html
<ol start="5">
  <li>Item 5</li>
  <li>Item 6</li>
  <li>Item 7</li>
</ol>
Try It Yourself

📚 Common Use Cases

Use <li> for feature lists, navigation menus, breadcrumbs, step instructions, outlines, and any grouped collection where each entry is a distinct list item.

Unordered List

Bullet-point lists with <ul> and <li>.

unordered-list.html
<ul>
  <li>Item A</li>
  <li>Item B</li>
  <li>Item C</li>
</ul>

Ordered List

Numbered lists with <ol> when sequence matters.

ordered-list.html
<ol>
  <li>First Item</li>
  <li>Second Item</li>
  <li>Third Item</li>
</ol>

Nested List

Place a sub-list inside an li for hierarchical content.

nested-list.html
<ul>
  <li>Main Item 1
    <ul>
      <li>Subitem A</li>
      <li>Subitem B</li>
    </ul>
  </li>
  <li>Main Item 2</li>
</ul>
Try It Yourself

Navigation Menu

Structure nav links as list items — often wrapped in <nav>.

nav-menu.html
<nav>
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/about">About</a></li>
    <li><a href="/contact">Contact</a></li>
  </ul>
</nav>
Try It Yourself

Steps in a Process

Use ol and li for ordered instructions.

steps-list.html
<ol>
  <li>Open the application</li>
  <li>Click on the "File" menu</li>
  <li>Select "Save As"</li>
</ol>

Styling <li> with CSS

Style list items and their markers with CSS on the parent list or individual items:

list-style-type Bullets or numbers
list-style-position Inside vs outside
:last-child Style final item
list-style: none Nav menu reset
list-styles.css
/* 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;
}

Live styled nav list

♿ Accessibility

Semantic lists help assistive technology convey structure:

  • Use ul/ol + li — not divs with manual bullet characters.
  • Wrap nav in <nav> — when a list serves as site navigation.
  • Keep list order meaningful — especially in ordered lists for instructions.
  • Do not skip heading levels inside lists — use proper headings if sections need titles beyond the list itself.

🧠 How <li> Works

1

Author creates ul or ol

Choose unordered or ordered list based on whether sequence matters.

Markup
2

Each entry is an li

Wrap every list entry in <li> tags.

Structure
3

Browser renders markers

Bullets for ul, numbers for ol.

Rendering
=

Structured, scannable content

Users and screen readers understand list length, order, and hierarchy.

Universal Browser Support

The <li> element is fully supported in all browsers, including legacy Internet Explorer.

Baseline · Since HTML 2

List items that work everywhere

From legacy Internet Explorer to the latest mobile browsers — li inside ul and ol is fully supported.

100% Core tag support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
<li> tag 100% supported

Bottom line: Ship lists with confidence. The <li> element is safe to use in every production environment today.

Conclusion

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.

💡 Best Practices

✅ Do

  • Wrap every list entry in <li>
  • Use ul for unordered and ol for ordered lists
  • Wrap navigation lists in <nav>
  • Use value on li only inside ol

❌ Don’t

  • Place li outside ul, ol, or menu
  • Use divs with bullet characters instead of real lists
  • Confuse start (on ol) with value (on li)
  • Use ol when item order does not matter

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <li>

Bookmark these before you ship — they’ll keep your lists semantic and accessible.

6
Core concepts
🔗 02

Needs a Parent

Must live inside ul, ol, or menu.

Syntax
⚖️ 03

ul vs ol

Bullets vs numbers — pick the right parent.

Comparison
📑 04

Nested Lists

Sub-lists go inside an li.

Structure
🔢 05

value on ol li

Custom numbering for ordered items only.

Attributes
06

Universal Support

Works in every browser, including legacy IE.

Compatibility

❓ Frequently Asked Questions

It represents a single item in a list, used inside ul, ol, or menu.
No. li must have a list parent. Bare list items in the body are invalid HTML.
On 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.
Yes. Place a ul or ol inside an li to create sub-lists.
Yes. Full universal support in all modern and legacy browsers.

Practice HTML Lists

Try unordered, ordered, nested, and navigation lists in the interactive editor.

Try It Yourself →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful