🎉
Lesson Complete!
You now know all three HTML list types and how to use them correctly. On to Links!
📝 Phase 2 · Core HTML 🟢 Beginner Module 03

HTML Lists

⏱ 18 min read 📖 6 sections 🧩 5-question quiz 🏆 1 challenge
Course Progress29% complete
Lists are everywhere on the web — navigation menus, feature lists, steps, breadcrumbs. HTML provides three types of lists, each with a specific semantic purpose. Choosing the right list type communicates meaning to both users and search engines.

Unordered Lists <ul>

An unordered list is a collection of items where the order doesn't matter. Each item gets a bullet point by default. Use <ul> for things like feature lists, ingredients, or any group of items without a meaningful sequence.

Every item inside a <ul> must be wrapped in a <li> (list item) element. You can change the bullet style with the CSS property list-style-type — common values include disc, circle, square, and none.

HTMLUnordered List
<!-- Basic unordered list -->
<ul>
  <li>HTML</li>
  <li>CSS</li>
  <li>JavaScript</li>
</ul>

<!-- CSS to change bullet style -->
ul {
  list-style-type: square;  /* disc | circle | square | none */
}
💡
Only <li> is a valid direct child
A <ul> should only contain <li> elements as direct children. Putting a <p> or <div> directly inside a <ul> is invalid HTML. Content goes inside the <li>.

Ordered Lists <ol>

An ordered list renders items with sequential numbers. Use it when the order matters — step-by-step instructions, rankings, recipes, or legal clauses. Browsers automatically number <li> items starting at 1.

The <ol> element accepts two useful attributes: type controls the marker style (1, A, a, I, i) and start sets the starting number so you can resume a list or count from any value.

HTMLOrdered List Variants
<!-- Default numbered list -->
<ol>
  <li>Preheat the oven to 180°C</li>
  <li>Mix the dry ingredients</li>
  <li>Fold in the wet ingredients</li>
</ol>

<!-- Uppercase letters, starting from C -->
<ol type="A" start="3">
  <li>Third option</li>
  <li>Fourth option</li>
</ol>

<!-- Roman numerals -->
<ol type="I">
  <li>Introduction</li>
  <li>Main Body</li>
  <li>Conclusion</li>
</ol>
🔍
Use <ol> for instructions and steps
When you swap an <ol> for a <ul>, you lose semantic meaning. Search engines and assistive technologies use the list type to understand whether order is significant. Choose semantically.

Description Lists <dl>

A description list pairs terms with their definitions. It uses three elements: <dl> (the container), <dt> (description term), and <dd> (description detail). One <dt> can have multiple <dd> children, and multiple <dt> elements can share one <dd>.

Description lists are ideal for glossaries, FAQ pages, product specs, and any key-value metadata where you want semantic structure rather than just a table.

HTMLDescription List
<dl>
  <dt>HTML</dt>
  <dd>HyperText Markup Language — the structure of web pages.</dd>

  <dt>CSS</dt>
  <dd>Cascading Style Sheets — controls visual presentation.</dd>

  <dt>JavaScript</dt>
  <dd>The programming language of the web.</dd>
  <dd>Runs in the browser and on servers via Node.js.</dd>
</dl>
🎭
dl is underused but powerful
Many developers reach for tables or <div> pairs when <dl>/<dt>/<dd> is the semantically correct choice. For product pages, metadata, and FAQs, it's often the best fit.

Nested Lists

Lists can be nested inside other lists by placing a new <ul> or <ol> inside an <li> element. This is commonly used for hierarchical navigation menus, outlines, and multi-level content structures.

Keep nesting meaningful — avoid more than 2–3 levels deep, as it hurts readability. The nested list belongs inside the parent <li>, not after it.

HTMLNested Navigation Menu
<ul>
  <li><a href="/">Home</a></li>
  <li>
    <a href="/courses">Courses</a>
    <!-- Nested sub-menu -->
    <ul>
      <li><a href="/courses/html">HTML Basics</a></li>
      <li><a href="/courses/css">CSS Fundamentals</a></li>
      <li><a href="/courses/js">JavaScript 101</a></li>
    </ul>
  </li>
  <li><a href="/about">About</a></li>
</ul>
⚠️
Put nested lists inside the <li>
A common mistake is placing the nested <ul> after the closing </li> instead of before it. The nested list must live inside its parent <li> to be valid HTML.

Lists and Navigation

Navigation menus are almost universally built with <nav><ul><li><a> patterns. The unordered list provides the semantic structure of a collection of links; the <nav> landmark tells assistive technology it is site navigation. CSS then removes the default bullets and styles the links.

HTMLTypical Nav Menu Structure
<nav aria-label="Main navigation">
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/courses">Courses</a></li>
    <li><a href="/blog">Blog</a></li>
    <li><a href="/contact">Contact</a></li>
  </ul>
</nav>

/* CSS to remove bullets and make horizontal */
nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 1rem;
}
💡
Screen readers announce list count
When CSS removes list bullets, some screen readers may stop announcing how many items are in the list. Add role="list" to the <ul> if you remove list-style to preserve accessibility in Safari/VoiceOver.

Styling Lists with CSS

CSS gives you complete control over list appearance. The key properties are list-style-type (the marker shape), list-style-image (a custom image as a marker), and list-style-position (inside or outside the content box). You can also build fully custom bullets using the ::before pseudo-element.

CSSList Styling Techniques
/* Remove all default list styling */
ul, ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Custom bullet using ::before */
ul li::before {
  content: "→ ";
  color: #ef4444;
  font-weight: 700;
}

/* Custom image as bullet */
ul.custom {
  list-style-image: url('bullet.svg');
}

/* Marker inside content box */
ul.inside {
  list-style-position: inside;
}

/* Shorthand */
ul {
  list-style: square inside;
}
🔵
disc (default)
The default bullet for <ul> — a filled circle.
square
Solid square bullet — bolder look for design-heavy lists.
🔢
decimal (default ol)
Numbers 1, 2, 3… the default for ordered lists.
::before pseudo
Full control — use any character, emoji, or icon as a custom marker.
🧩 Quick Check — Lesson 10
5 questions · instant feedback · no penalty for wrong answers
1. Which HTML element creates a numbered list?
2. Which set of elements makes up a description list?
3. Where does a nested list go in the HTML structure?
4. Which CSS property removes the default bullet from a list?
5. A <li> element must be a direct child of which element(s)?
🏆
Quiz Complete!
Great work mastering HTML lists. Up next: links and anchors!
🏆
Lesson 10 Challenge
Coding exercise · ~15 min
Build a recipe page structure using all three list types:

• An <ol> for the numbered list of ingredients
• Under one ingredient (e.g. "Flour"), add a nested <ul> with two flour variation options
• A second <ol> for the step-by-step cooking instructions
• A <dl> with <dt>/<dd> pairs for nutritional info (e.g. Calories, Protein, Fat)

Add a heading above each section and wrap the whole page in semantic HTML structure.
Show hints
  • Use <h2> for "Ingredients", "Instructions", "Nutrition"
  • Nested <ul> goes inside one of the <li> items of the ingredients <ol>
  • For nutrition: <dt>Calories</dt><dd>320 kcal</dd>
  • Try styling the <dl> with CSS grid for a two-column layout
← Formatting Tags
Lesson 10 of 35HTML Fundamentals