Skip to content

HTML Tutorial Lists

Nested HTML Lists: Lists Inside Lists

Lesson 29 of 81 2 min read By Deepak Paswan Updated Oct 4, 2026

A list item can contain another list. This is how you show levels: topics and subtopics, a menu with a sub-menu, an outline.

index.html
HTML
<ul>
  <li>Fiction
    <ul>
      <li>Mystery</li>
      <li>Science fiction</li>
    </ul>
  </li>
  <li>Non-fiction
    <ul>
      <li>Biography</li>
      <li>Travel</li>
    </ul>
  </li>
</ul>

The rule

The inner list goes inside the li, after the text, not directly inside the outer ul. This is the most common nesting mistake.

index.html
HTML
<!-- Wrong -->
<ul>
  <li>Fiction</li>
  <ul>
    <li>Mystery</li>
  </ul>
</ul>

<!-- Right -->
<ul>
  <li>Fiction
    <ul>
      <li>Mystery</li>
    </ul>
  </li>
</ul>

Mixing list types

You can nest an ordered list inside an unordered one, and the other way around.

index.html
HTML
<ol>
  <li>Prepare
    <ul>
      <li>Boil water</li>
      <li>Find a cup</li>
    </ul>
  </li>
  <li>Brew</li>
</ol>
lightbulb
Keep it shallow
Three levels is plenty. Deeper lists are hard to read and hard to use with a keyboard or a phone.