Skip to main content.

Web Based Programming Tutorials

Homepage | Forum - Join the forum to discuss anything related to programming! | Programming Resources

How to use HTML 3.2

Chapter 7 -- Creating Lists in HTML

Chapter 7

Creating Lists in HTML


Everyone makes lists. Whether you use them for groceries, to-do items, or holiday gifts and cards, lists are an important part of your life.

Lists are also important on the World Wide Web. The environment of the Web calls for information to be presented in a concise and timely manner. Lists are ideal vehicles for delivering all kinds of information on line.

As an HTML author, you have many choices for how to create and present lists. In this chapter, we'll look at ways to create unordered lists, ordered (numbered) lists, and a special type of list known as a definition list. You'll also learn how to combine multiple levels of lists.

How to Create Unordered Lists

The simplest list in HTML is the unordered, or bulleted, list. This is ideal for listing items that have no particular hierarchy or order of importance. Unordered lists are very common on the Web and are used to convey items of note in a quick and concise manner. Web browsers usually place bullets or other markers in front of each item in an unordered list.

Tip Sheet

  1. Locate the part of your HTML document where you want to insert a list.
  2. Begin the unordered list by typing <UL>, and then press Enter. The <UL> tag tells the Web browser to treat this section of text as an unordered list. Unordered lists will usually be indented from the main document and list items will be formatted with bullets. The size and type of bullets used are determined by the Web browser.

    Figure 7.2 :

  3. Create a heading for your list. This is an optional brief description of what your list contains. To create a list header, type <LH>, followed by a brief summary of the list contents. Then type </LH> to close the list heading tag. For example, to create a list heading for a grocery list, you would type <LH>My Grocery List</LH>.

    Figure 7.3 :

  4. To create the first item in your list, type <LI>. Then type the text of the item itself. <LI> is an open tag, which means that you do not need to type </LI> at the end of each item.

    Figure 7.4 :

  5. Continue typing <LI> followed by text for each item in your list. Press Enter after each item.
  6. Finish the unordered list by typing </UL>.

    Figure 7.5 :

How to Create Ordered Lists

Sometimes you need to list items in a specific order. Examples of this type of list include step-by-step instructions and "Top 10" lists. HTML provides a way to do this through ordered lists. Web browsers will place a number in front of each item, increasing the number by one for each entry down the list.

Tip Sheet

  1. To create an ordered list, locate the place in your document where you'd like to begin the list and type <OL>.

    Figure 7.7 :

  2. To create an optional heading for the ordered list, type <LH> followed by the heading. Then close the heading tag by typing </LH>.

    Figure 7.8 :

  3. To enter the first item of your list, type <LI> followed by the item. There is no need to include a closing </LI> tag.

    Figure 7.9 :

  4. Type </OL> to close the ordered list.

    Figure 7.10 :

How to Create Definition Lists

Definition lists are different from other lists in HTML, because each item in a definition list contains two parts: a term and a definition. Definition lists are typically used for glossaries and dictionaries. With a little creativity, however, they can be put to use in many different ways, such as product catalogs and even poetry.

Tip Sheet

  1. To create a definition list in your HTML document, type <DL> at the point where you'd like the list to begin.

    Figure 7.12 :

  2. As mentioned earlier, definition lists are slightly different from ordered and unordered lists. Each item in a definition list is made up of two separate parts: the term and the definition. Typically, browsers will display the term on one line and the definition indented on the next line.

    Figure 7.13 :

  3. To create a definition term, type <DT> followed by text describing the element being defined. For example, to begin a definition of the word apple, you would type <DT>Apple.

    Figure 7.14 :

  4. To create the definition, type <DD>, followed by the text of the definition. For example, to create a definition for the term in the previous step, you would type <DD>a firm, edible, rounded fruit.

    Figure 7.15 :

  5. As with ordered and unordered lists, there are no closing tags for list items. Therefore, it is not necessary to type </DT> or </DD> at the end of your terms and definitions.
  6. Type </DL> to close your definition list.

    Figure 7.16 :

How to Create Lists within Lists

In the beginning of this chapter, we learned that lists are extremely flexible and powerful tools in HTML. Sometimes you'll want to create lists within lists, especially when you need to create a hierarchy of items, such as in outlines or detailed instructions. Creating lists within lists is easy in HTML.

Tip Sheet

  1. Begin the first list by typing <OL>. In this example, we're assuming that the first list is an ordered list, but in reality, it can be any type of list you want.

    Figure 7.18 :

  2. Enter your list items one by one, beginning each item with <LI>.

    Figure 7.19 :

  3. When you reach a step that requires a nested list, begin another list. The Web browser will automatically format this new list to fall underneath the current item in the first list. For example, to create a nested list under Step 2 in your original list, just type <UL>.

    Figure 7.20 :

  4. Start entering items in your new list. When you're finished, close the new list by typing </UL>. You must close the new list before continuing to enter items in the original list.

    Figure 7.21 :

  5. Enter the remaining items in the original list. Then press Enter and type </OL> when you're finished.

    Figure 7.22 :