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:

  
    
    Nested Lists
  
  
    

Things to do today

  1. Feed cat
    • Rinse bowl
    • Open cat food
    • Mix dry and wet food in bowl
    • Deliver on a silver platter to Pixel
  2. Wash car
    • Vacuum interior
    • Wash exterior
    • Wax exterior
  3. Grocery shopping
    • Plan meals
    • Clean out fridge
    • Make list
    • Go to store

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.

image0.jpg

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: