logo logo

Changing the Style and Sequence of Individual List Items

Just as you can change the bullet or numbering style for all of the items in an unordered or ordered list, you also can change the style for individual items within those lists. With ordered lists, you also can change the value of the item number. As you’ll see, the combinations of changing style and numbering can lead to a variety of useful list structures, particularly when included with nested lists.

The type attribute

Acceptable values for the type attribute in the <li> tag are the same as the values for the appropriate list type: items within unordered lists may have their type set to circle, square, or disc, while items in an ordered list may have their type set to any of the values shown previously in Table 8.1. The change affects the current item and any subsequent items in the list.

There is no way to revert back to the list’s default type once you have changed the type for a single item; you’ll need to explicitly reset the type on the next item. Thus, to make a single item in a list different from the rest, you’ll need to change two items: the actual item you want changed, and the next item, which must be changed back to the general list format.

Figure 8.4 shows the effect that changing the type for an individual item in an ordered list has on subsequent items, as rendered by Netscape from the following source:

<ol>
  <li type=A>Changing the numbering style
  <li type=a>Doesn't alter the order!
  <li> &lt;-- See? It's a "c"!
  <li type=I>Uppercase Roman numerals!
  <li type=i>Lowercase Roman numerals!
  <li type=1>Plain ol' numbers!
</ol>

Notice how the type attribute changes the display style of the number, but not the value of the number itself.

The value attribute

The value attribute lets you change the number of a specific list item and the ones that follow it. Since the ordered list is the only HTML list with sequentially numbered items, the value attribute is only valid when used within an <li> tag inside an ordered list.

To change the current and subsequent numbers attached to each item in an ordered list, simply set the value attribute to any integer. For example, the following source uses the value attribute to jump the numbering on items in an ordered list:

<ol>
  <li>Item number 1
  <li>And the second
  <li value=9> Jump to number 9
  <li>And continue with 10...
</ol>

The results are shown as rendered by Netscape in Figure 8.5.

bottom

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

bottom