HTML Lists — ul, ol, dl & Nested Lists
Lists are everywhere on the web — navigation menus, feature lists, step-by-step guides, definition glossaries. HTML provides three powerful list elements for every use case. In this chapter you'll master all three, learn how to nest them, customise their appearance, and apply accessibility best practices.
<ul>, <ol>, <dl>type,
start, reversed
<dt> and <dd>list-style-typeThe Three HTML List Types
HTML gives you three distinct list elements, each designed for a different kind of content. Choosing the right list type is both a semantic and accessibility decision.
- HTML gives structure
- CSS gives style
- JavaScript adds behaviour
- Create the HTML file
- Add content and tags
- Open in browser
- HTML
- HyperText Markup Language
- CSS
- Cascading Style Sheets
Unordered List — <ul>
An unordered list wraps a collection of <li>
(list item) elements. Each item renders with a bullet marker — disc by default. Use it whenever the order of
items is not meaningful.
<ul>
<li>HTML — builds the structure</li>
<li>CSS — styles the structure</li>
<li>JavaScript — adds interactivity</li>
</ul>
Ordered List — <ol>
An ordered list also wraps <li> elements,
but renders them with sequential numbers (or letters/roman numerals) by default. Use it whenever the order
is meaningful — steps, rankings, instructions.
<!-- Basic numbered list -->
<ol>
<li>Download VS Code</li>
<li>Create index.html</li>
<li>Write your HTML</li>
<li>Open in browser</li>
</ol>
<!-- Start from a custom number -->
<ol start="5">
<li>Step five</li>
<li>Step six</li>
</ol>
<!-- Reversed countdown -->
<ol reversed>
<li>Gold medal winner</li>
<li>Silver medal winner</li>
<li>Bronze medal winner</li>
</ol>
<!-- Uppercase letters -->
<ol type="A">
<li>Option A</li>
<li>Option B</li>
<li>Option C</li>
</ol>
| Attribute | Applied To | Purpose | Example |
|---|---|---|---|
| type | <ol> |
Sets the marker type — 1 (default), A, a, I, i |
type="A" |
| start | <ol> |
Sets the starting number for the list counter — useful for continuing a list split across sections | start="5" |
| reversed | <ol> |
Counts downward instead of up — useful for countdowns or reverse rankings | reversed |
| value | <li> |
Overrides the counter for a specific item — subsequent items continue from the new value | value="10" |
Description List — <dl>, <dt>, <dd>
A description list groups term–definition pairs using three elements:
<dl> (the container), <dt> (the term), and <dd>
(the description). One term can have multiple descriptions, and multiple terms can share one description.
<!-- Glossary of web terms -->
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language — the structure of a web page.</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets — controls colours, fonts, and layout.</dd>
<dt>JavaScript</dt>
<dd>A programming language that adds interactivity to web pages.</dd>
<dd>Also used on the server via Node.js.</dd>
</dl>
<dl> for glossaries, FAQ answer pairs, product metadata
(weight, dimensions, colour), author bios, or any key–value data. It is semantically richer than using a
table for this purpose.
Nested Lists — Lists Inside Lists
You can place any list type inside a <li>
element to create nested lists. This is essential for multi-level navigation menus, site maps, and
hierarchical content. The key rule is to always nest the child <ul> or <ol> inside
the parent <li> — never directly inside <ul> or <ol>.
<!-- Nested unordered list (nav menu) -->
<ul>
<li>Courses
<ul>
<li>Web Development</li>
<li>Python Masterclass</li>
<li>Data Analysis</li>
</ul>
</li>
<li>Tutorials
<ul>
<li>HTML Tutorial</li>
<li>CSS Tutorial</li>
</ul>
</li>
<li>About Us</li>
</ul>
<!-- Nested ordered inside unordered -->
<ul>
<li>Frontend Technologies
<ol>
<li>HTML (learn first)</li>
<li>CSS (learn second)</li>
<li>JavaScript (learn third)</li>
</ol>
</li>
</ul>
<ul> directly inside another <ul> without a wrapping <li>. The child list must always live inside a <li> — otherwise the HTML is invalid.
Customising Lists with CSS list-style-type
The CSS list-style-type property changes the
marker style of any list. Here are the most commonly used values:
- Filled circle
- Default for ul
- Hollow circle
- Nested ul default
- Filled square
- Useful for sub-items
- Default for ol
- 1, 2, 3...
- Uppercase A, B, C
- Great for exam options
- Roman numerals I, II
- Formal documents
- Lowercase a, b, c
- Sub-steps and options
- No marker at all
- Used for nav menus
/* Remove bullets — used on navigation menus */
nav ul {
list-style-type: none;
margin: 0;
padding: 0;
}
/* Custom marker colour via ::marker pseudo-element */
ul li::marker {
color: #e44d26;
}
/* Remove default styling and add custom padding */
ul, ol {
padding-left: 24px;
}
/* Uppercase letter list */
ol.options {
list-style-type: upper-alpha;
}
Common Mistakes — Do's & Don'ts
These are the most frequent list mistakes beginners make:
<!-- Child list inside <li> -->
<ul>
<li>Courses
<ul>
<li>HTML</li>
<li>CSS</li>
</ul>
</li>
</ul>
<!-- ol for ordered steps -->
<ol>
<li>Download VS Code</li>
<li>Create HTML file</li>
</ol>
<!-- Nested list NOT inside <li> (invalid) -->
<ul>
<li>Courses</li>
<ul> ← wrong! must be inside <li>
<li>HTML</li>
</ul>
</ul>
<!-- ol used for unordered content -->
<ol>
<li>Apples</li>
<li>Mangoes</li>
</ol>
Complete Example — Lists in a Real Page
Here is a realistic HTML snippet combining all three list types in a typical web page context:
<section>
<h2>Course Features</h2>
<!-- Unordered: order doesn't matter -->
<ul>
<li>120+ video lessons</li>
<li>10 real-world projects</li>
<li>Placement support</li>
<li>Certificate on completion</li>
</ul>
<h2>How to Enroll</h2>
<!-- Ordered: sequence matters -->
<ol>
<li>Visit <a href="/courses.html">our courses page</a></li>
<li>Choose a course</li>
<li>Click Enroll and complete payment</li>
<li>Start learning immediately</li>
</ol>
<h2>Course Details</h2>
<!-- Description: term–value pairs -->
<dl>
<dt>Duration</dt>
<dd>40 hours of recorded content</dd>
<dt>Level</dt>
<dd>Beginner to Advanced</dd>
<dt>Language</dt>
<dd>English & Hindi</dd>
</dl>
</section>
Try It Yourself
Edit the lists below and click Open in Editor to see them live in full screen.
type="1" on the <ol> to
type="A", type="a", or type="I" and watch the markers change. Try adding reversed or start="5" as attributes too.
Quick Check — Chapter 8
Expand each question to check your understanding before moving on to the multiple choice quiz below.
<ul> (unordered list) is used when the order of items
does not matter — it renders bullet points by default. <ol> (ordered list) is used when sequence is
meaningful — it renders numbered markers by default. The rule of thumb: if you could
rearrange the items without changing their meaning, use <ul>.
If the order matters (steps, rankings, top 10 lists), use <ol>. Choosing the wrong one is a semantic error that affects
accessibility and SEO.
<dl> (description
list) is the outer container — it wraps the entire list. <dt> (description term) defines the term or name
being described — rendered bold by default. <dd> (description
details) provides the definition or value for the preceding term — rendered with left
indentation by default. One <dt> can be followed by multiple
<dd> elements, and multiple <dt> elements can share one <dd>.
<li>
element of the parent list — never directly inside a <ul> or <ol>. The
correct structure is: <ul> <li>Parent item <ul> <li>Child</li> </ul> </li> </ul>.
Placing the child <ul> directly after a </li> but still inside the outer <ul> is invalid HTML and causes unpredictable rendering.
type attribute changes the marker style — values are 1 (numbers, default), A (uppercase
letters), a (lowercase letters), I (uppercase Roman numerals), and i
(lowercase Roman numerals). The start attribute sets the
starting number — for example start="5" begins
counting at 5, which is useful for lists split across sections. The reversed attribute makes the list count downward —
useful for countdowns or reverse rankings.
<ul> and <li> because a nav menu is genuinely a list of links. However,
bullet markers are not visually appropriate for a horizontal or styled navigation bar. list-style-type: none removes the bullet markers entirely, while padding: 0; margin: 0 removes the default indentation — giving you a
clean foundation to style the links with flexbox or CSS grid. This is the standard pattern used by every
professional web developer.
::marker CSS pseudo-element targets the marker
box of a list item — the bullet or number that appears before each <li>. Using it you can change the marker's colour, font size, or
content without needing to wrap items in extra elements. For example: li::marker { color: #e44d26; font-weight: 700; } changes all bullets to
orange and bold. It has broad browser support as of 2023 and is the modern, clean way to style list
markers.
<ol> makes the list
count downward instead of up?<ul>— unordered list with bullet points. Use when order does not matter (features, ingredients, nav links).<ol>— ordered list with numbers. Use when sequence matters (steps, rankings, instructions). Supportstype,start, andreversedattributes.<dl>with<dt>and<dd>— description list for term–definition pairs. Use for glossaries, FAQs, and metadata.- All three list types use
<li>for items — except<dl>which uses<dt>and<dd>. - Nested lists must always place the child
<ul>or<ol>inside a<li>— never directly inside the parent list element. - Use CSS
list-style-type: noneto remove markers — standard for navigation menus. Use::markerto change marker colour or style.
Rate Us on Google
Join Our Learning Community
Connect with thousands of learners, get daily tips, ask questions, and stay updated with new tutorials.