Why lists matter
Lists are one of the most common content patterns on the web. Whether you're showing navigation links, recipe ingredients, numbered steps, or glossary terms, HTML lists help you organize information in a way that's both semantic (meaningful to browsers and search engines) and visually clear.
HTML gives you three types of lists:
- Unordered lists (
<ul>) โ bullet points, when order doesn't matter - Ordered lists (
<ol>) โ numbered steps, rankings, or sequences - Description lists (
<dl>) โ term-definition pairs, like a glossary or FAQ
Unordered lists with <ul>
An unordered list displays items with bullet points. Use it when the sequence doesn't matter โ like a shopping list, features, or options.
Each list item goes inside an <li> (list item) tag, and all items are wrapped in a <ul> tag. The <ul> itself doesn't display โ it's just a container that tells the browser "this is an unordered list."
Ordered lists with <ol>
Use ordered lists when sequence or ranking matters. Recipes, step-by-step instructions, top-10 lists, and algorithms all belong in <ol> tags.
By default, <ol> uses Arabic numerals (1, 2, 3...). But you can customize the numbering with the type attribute and the start attribute.
Ordered list attributes
The <ol> tag supports powerful attributes to control numbering:
Here's a quick reference:
type="1"(default) โ Arabic numerals: 1, 2, 3...type="A"โ Uppercase letters: A, B, C...type="a"โ Lowercase letters: a, b, c...type="I"โ Roman numerals (uppercase): I, II, III...type="i"โ Roman numerals (lowercase): i, ii, iii...start="N"โ Start counting at number N instead of 1reversedโ Count down instead of up
Nested lists
You can nest lists inside other lists. This is perfect for outlines, tables of contents, or multi-level hierarchies. Just place a list inside an <li> element.
<li> tag, not after it. Follow the golden rule: close </li> after the nested list, not before.
Description lists for glossaries
Description lists are perfect for glossaries, FAQ sections, or any term-definition pairs. They use three tags:
<dl>โ The description list container<dt>โ The term (definition term)<dd>โ The definition (description)
Description lists are semantic and accessible. Screen readers understand the relationship between terms and definitions, making your content more usable for everyone.
Try it yourself: Recipe page
Let's combine unordered and ordered lists in a real recipe page. Edit the code to change the recipe or add more ingredients and steps.
When to use each list type
Choosing the right list type makes your content clearer and more semantic:
When the sequence doesn't matter. Examples: shopping lists, features, options, bullet-point summaries, navigation menus, checklist items (unordered).
When sequence or priority matters. Examples: step-by-step instructions, rankings, recipes, numbered steps, algorithms, countdowns.
For term-definition pairs. Examples: glossaries, FAQs, definitions, metadata (key-value pairs), specifications with descriptions.
Task: Create a packing list page with:
- An
<h1>title: "Travel Packing List" - An
<ol>section "Packing Steps" with 4-5 steps - A
<ul>section "Essential Items" with: - A nested
<ul>for "Clothing" (3 items) - A nested
<ul>for "Toiletries" (3 items) - A nested
<ul>for "Electronics" (3 items) - A
<dl>section with a "Travel Glossary" (4 terms and definitions)
Hint: Start with an <h1>. Add the packing steps as <ol>, then create the essential items section with <ul> and nested <ul> elements inside each <li>. Finally, add a <dl> with travel terms and definitions. Use the editors above as templates!
Common mistakes
- Forgetting the container tag โ List items must be inside
<ul>,<ol>, or<dl>. Bare<li>tags outside a list won't render correctly. - Using <ul> for step-by-step instructions โ If order matters, use
<ol>instead. It's more semantic and helps readers understand the sequence. - Nesting in the wrong place โ Place nested lists inside the
<li>, not after it. Wrong:<li>Item</li><ul>. Right:<li>Item<ul>...</ul></li> - Misusing description lists โ
<dl>is not a general two-column layout tool. Use it only for term-definition relationships. For other purposes, use tables or divs with CSS. - Forgetting to close list item tags โ While some browsers auto-close
<li>, always explicitly close them. It's a best practice for clean, valid HTML.
Key takeaways
- Use
<ul>for unordered lists โ bullet points when sequence doesn't matter. - Use
<ol>for ordered lists โ numbered steps when sequence matters. Customize withtype,start, andreversed. - Use
<dl>for glossaries โ term-definition pairs are semantic and accessible. - Nest lists inside
<li>elements to create hierarchies. Always close tags properly. - Lists are semantic โ They help screen readers, search engines, and humans understand content structure.
Test your knowledge
You just mastered lists.
Your web pages are getting structured.
Join the Best AI Programs โ three 5-month courses, fully online, with placement assistance. Week 1 is free.
Explore our AI-era courses โ