HTML Reference
<ul> & <ol> — List Elements
The two list elements that structure content, navigation, and steps. Plus the description list family.
Last updated: October 2026
Definition: HTML has three list elements — <ul> (unordered, bullet points), <ol> (ordered, numbered), and <dl> (description, term-definition pairs). List items inside ul and ol are wrapped in <li>.
🎬 Live Example
The three list types, side by side.
- HTML
- CSS
- JavaScript
- Install Node.js
- Create a project
- Run the server
- HTML
- Structure of the web
- CSS
- Styling and layout
💡 Choose based on meaning, not appearance. Use <ol> whenever sequence matters.
Basic Syntax
<!-- Unordered list -->
<ul>
<li>Item one</li>
<li>Item two</li>
<li>Item three</li>
</ul>
<!-- Ordered list -->
<ol>
<li>First step</li>
<li>Second step</li>
<li>Third step</li>
</ol>
⚙️ Attributes Reference
Only <ol> has specific attributes. <ul> and <li> use only global attributes.
| Element | Attribute | Purpose |
|---|---|---|
<ol> | type | Numbering style: 1 (default), A, a, I, i. |
<ol> | start | Start number. Default 1. |
<ol> | reversed | Reverse the numbering. |
<li> | value | Override the number for this item only. |
| All | id, class, style, etc. | Global attributes. |
Unordered List <ul>
Use when the order of items doesn't matter. Renders as bullet points by default.
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
Common uses:
- Feature lists on a landing page
- Navigation menus (with CSS list-style: none)
- Ingredients, tags, categories
- Bullet point lists in articles
Ordered List <ol>
Use when the sequence of items matters. Renders as numbered steps.
<ol>
<li>Install Node.js</li>
<li>Run npm install</li>
<li>Start the dev server</li>
</ol>
Advanced usage with type, start, and reversed:
<!-- Start from 5 -->
<ol start="5">
<li>Fifth item</li>
<li>Sixth item</li>
</ol>
<!-- Uppercase letters -->
<ol type="A">
<li>Option A</li>
<li>Option B</li>
</ol>
<!-- Roman numerals, reversed -->
<ol type="I" reversed>
<li>Countdown 3</li>
<li>Countdown 2</li>
<li>Countdown 1</li>
</ol>
Nested Lists
Place a nested <ul> or <ol> inside an <li> to create a sublist.
<ul>
<li>Frontend
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
</li>
<li>Backend
<ul>
<li>Node.js</li>
<li>Python</li>
<li>PostgreSQL</li>
</ul>
</li>
</ul>
This renders with increasing indentation for each level. Use it for outlines, file trees, and multi-level navigation.
Description List <dl>
Term-definition pairs. Use it for glossaries, FAQs, and metadata.
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language. The structure of the web.</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets. Styling and layout.</dd>
<dt>JavaScript</dt>
<dd>The programming language of the web.</dd>
</dl>
You can also have multiple <dd> elements per <dt>:
<dl>
<dt>Coffee</dt>
<dd>Hot beverage made from roasted beans.</dd>
<dd>Also a programming term: "Java" is not "JavaScript".</dd>
</dl>
Styling Lists
Common CSS patterns for lists.
/* Remove bullets (great for navigation menus) */
ul.no-bullets {
list-style: none;
padding: 0;
}
/* Custom bullet with an emoji or icon */
ul.custom li::before {
content: "→ ";
color: #3b82f6;
font-weight: 700;
}
/* Horizontal nav from a ul */
nav ul {
display: flex;
gap: 1.5rem;
list-style: none;
padding: 0;
}
/* Remove default padding from lists */
ul, ol {
padding-left: 1.25rem;
}
/* Space out list items */
li {
margin-bottom: 0.5rem;
}
🎯 Choosing the Right List Type
| Element | Use when | Example |
|---|---|---|
<ul> | Order doesn't matter | Features, tags, related links |
<ol> | Order matters | Tutorial steps, rankings |
<dl> | Term-definition pairs | Glossaries, FAQs, metadata |
<div> | Not a list | Navigation menus (still use <ul>!) |
💡 Important: Even navigation menus should use <ul> for the links. Then use CSS to make it horizontal. Screen readers announce the list structure.
⚠️ Common Mistakes
- Using
<ul>for steps in a tutorial. If the order matters, use<ol>. Screen readers announce "1 of 5," "2 of 5," etc. - Using
<div>for navigation lists. Use<ul><li><a>. Then style with CSS. Screen readers announce the number of items. - Putting text directly inside
<ul>or<ol>. Every item must be wrapped in<li>. Direct text produces invalid HTML. - Removing
list-stylewithout replacing the visual cue. Navigation menus need clear hover states and spacing. Just removing bullets doesn't make it usable. - Using
<dl>for layout. It's for term-definition pairs, not generic two-column layouts. Use CSS Grid for that. - Nesting lists outside the
<li>. The nested list must be inside the parent<li>, not after it. Otherwise the structure is broken. - Using lists for paragraph content. If it's not a list of items, use
<p>. Lists have meaning.
♿ Accessibility Notes
- Screen readers announce list structure. "List with 5 items," "bullet," "item 1 of 5," etc. This helps users understand grouping and quantity.
- Never use
<div>where a list is appropriate. Divs convey no grouping. Users lose the count and structure. - Ordered lists announce the number. Screen readers say "1", "2", "3". This is why
<ol>matters for steps. - Nested lists preserve the hierarchy. Screen readers announce "level 2 list" for sublists, making the structure navigable.
- Do not remove list semantics with CSS. You can hide bullets with
list-style: none, but keepdisplay: list-itemor addrole="list"if you must use another display type. - For navigation menus: wrap in
<nav><ul><li><a>. Screen readers announce "navigation list with 5 items."
❓ Frequently Asked Questions
What is the difference between ul and ol?
ul (unordered list) is for items where order doesn't matter — bullet points. ol (ordered list) is for items where sequence matters — numbered steps. Choose based on meaning, not appearance.
What is the li tag?
li (list item) is the child element of ul and ol. Every item in a list is wrapped in li. You cannot have a ul or ol without li children.
What is the dl tag?
dl (description list) is for term-definition pairs. It contains dt (description term) and dd (description details). Use it for glossaries, FAQs, and metadata.
Can I nest lists?
Yes. Place a nested ul or ol inside an li element. This creates sublists for multi-level content like outlines or navigation menus.
How do I remove the bullet points from a list?
Use CSS: list-style: none. This is common for navigation menus built with ul. Never remove list semantics — screen readers still announce the list correctly.