HTML: The Definitive Guide

Previous Chapter 7 Next
 

7.2 Ordered Lists

Ordered lists are used when the sequence of the list items is important. A list of instructions is a good example, as are tables of content and lists of document footnotes or endnotes.

The <ol> Tag

The typical browser formats the contents of an ordered list just like an unordered list, except that the items are numbered instead of bulleted. The numbering starts at 1 and is incremented by one for each successive ordered list element tagged with <li>. [<li>, 7.7.3]

In standard HTML 2.0 you can't start numbering at some value other than one, increment by a value other than one, or number the items with anything but whole Arabic numerals. Netscape and Internet Explorer, on the other hand, offer extensions that let you do all those things.

A sample ordered list might be:

<h3>Pickled Kumquats</h3>
Here's an easy way to make a delicious batch of pickled 'quats:
<ol>
  <li>Rinse 50 pounds of fresh kumquats
  <li>Bring eight gallons white vinegar to rolling boil
  <li>Add kumquats gradually, keeping vinegar boiling
  <li>Boil for one hour, or until kumquats are tender
  <li>Place in sealed jars and enjoy!
</ol>

This is rendered by Netscape as shown in Figure 7-2.

Compact ordered lists

Like the unordered list, the ordered list in HTML has an optional compact attribute. When instructed to compact the ordered list, the browser may reduce the indentation, reduce the amount of space between the sequence numbers and the list items, or both. Some browsers cannot compact and so do nothing.

The start attribute

Normally, browsers automatically number ordered list items beginning with the Arabic numeral 1. The start attribute is used by Netscape and Internet Explorer with the <ol> tag to let you change that beginning value. To start numbering a list at 5, for example:

<ol start=5>
  <li> This is item number 5.
  <li> This is number six!
  <li> And so forth...
</ol>

Changing the numbering style in ordered lists

By default, browsers number ordered list items with a sequence of Arabic numerals. Besides being able to start the sequence at some number other than 1, Netscape and Internet Explorer also let you use a type attribute with the <ol> tag to change the numbering style itself. With the <ol> tag, the type attribute may have a value of ``A'' for numbering with capital letters, ``a'' for numbering with lowercase letters, ``I'' for capital Roman numerals, ``i'' for lowercase Roman numerals, or ``1'' for common Arabic numerals. (See Table 7.1).

Table 7-1: Netscape and Internet Explorer Type Values for Numbering Ordered Lists
Type Value Generated Style Sample Sequence
A Capital letters A, B, C, D
a Lowercase letters a, b, c, d
I Capital Roman numerals I, II, III, IV
i Lowercase Roman numerals i, ii, iii, iv
1 Arabic numerals 1, 2, 3, 4

The start and type attribute extensions work in tandem. The start attribute sets the starting value of the item integer counter at the beginning of an ordered list. The type attribute sets the actual numbering style. For example, the following ordered list starts numbering items at 8, but because the style of numbering is set to i, the first number is the lowercase Roman numeral, ``viii.'' Subsequent items are numbered with the same style, each value incremented by 1 as shown in (Figure 7-3):

<ol start=8 type="i">
  <li> This is the Roman number 8.
  <li> The numerals increment by 1.
  <li> And so forth...
</ol>

The type and value of individual items in a list can be different from the list as a whole, as described in the next section.


Previous Home Next
Unordered Lists Book Index The <li> Tag
 


Banner.Novgorod.Ru