Beginning HTML5 and CSS3 For Dummies
Book image
Explore Book Buy On Amazon

Just about anything fits in a list, from sets of instructions to collections of links. You can create subcategories by nesting lists within lists. Some common uses for nested lists include the following:

  • Site maps and other navigation tools

  • Tables of content for online books and papers

  • Outlines

You can combine any of the three kinds of lists to create nested lists, such as a multilevel table of contents or an outline that mixes numbered headings with bulleted list items as the lowest outline level.

The following example starts with a numbered list that defines a list of things to do for the day and uses three bulleted lists to break down those items further into specific tasks:

<!DOCTYPE html>
    <meta charset="UTF-8">
    <title>Nested Lists</title>
    <h1>Things to do today</h1>
      <li>Feed cat
          <li>Rinse bowl</li>
          <li>Open cat food</li>
          <li>Mix dry and wet food in bowl</li>
          <li>Deliver on a silver platter to Pixel</li>
      <li>Wash car
          <li>Vacuum interior</li>
          <li>Wash exterior</li>
          <li>Wax exterior</li>
      <li>Grocery shopping
          <li>Plan meals</li>
          <li>Clean out fridge</li>
          <li>Make list</li>
          <li>Go to store</li>

All nested lists follow the same markup pattern:

  • Each list item in the top-level ordered list is followed by a complete second-level list.

  • The second-level lists sit inside the top-level list, not in the list items.

This figure shows how a browser reflects this nesting in its display.


While you build nested lists, watch opening and closing tags carefully. “Close first what you opened last” is an important axiom. If you don’t open and close tags properly, lists might not use consistent indents or numbers, or text might be indented incorrectly because a list somewhere was never properly closed.

About This Article

This article is from the book:

About the book authors:

Ed Tittel is a 30-year veteran of the technology industry with more than 140 computing books to his credit, including the bestselling HTML For Dummies.

Chris Minnick runs Minnick Web Services. He teaches, speaks, and consults on web-related topics and has contributed to numerous books, including WebKit For Dummies.

This article can be found in the category: