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

Lists are powerful tools to group similar elements, and lists give visitors to your site an easy way to zoom in on groups of information. Just about anything fits in a list, from sets of instructions to collections of links. A numbered list consists of at least two items, each prefaced by a number. Use a numbered list when the order or priority of items is important.

You use two kinds of elements for a numbered list:

  • The ordered list element (

      ) specifies a numbered list.

    1. List item elements (

    2. ) mark each item in the list.

A numbered list with three items requires elements and content in the following order:

    1. Content for the first list item

    2. Content for the second list item

    3. Content for the third list item

The following markup defines a three-item numbered list:

<!DOCTYPE html>
    <meta charset="UTF-8">
    <title>Numbered Lists</title>
    <h1>Things to do today</h1>
      <li>Feed cat</li>
      <li>Wash car</li>
      <li>Grocery shopping</li>

This figure shows how a browser renders this markup. You don’t have to specify a number for each item in a list; the browser identifies list items from the markup and adds numbers, including a period after each one by default.


If you swap the first two items in the list, they’re still numbered in order when the page appears, as shown in this figure.

      <li>Wash car</li>
      <li>Feed cat</li>
      <li>Grocery shopping</li>

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: