It should be quite obvious to you by now that the <li> tag defines an item in a list. It's the universal tag for HTML list items in ordered (<ol>) and unordered (<ul>) lists, as we discuss above, and for directories (<dir>) and menus (<menu>), which we discuss in detail below.
Because the end of a list element can always be inferred by the surrounding document structure, most authors omit the ending </li> tags for their list elements. That makes sense because it becomes easier to add, delete, and move elements around within a list, so we recommend not using the </li> end tag.
Although universal in meaning, there are some differences and restrictions to the use of the <li> tag for each HTML list type. In unordered and ordered lists, what follows the <li> tag may be nearly anything, including other lists and multiple paragraphs. Typically, if it handles indentation at all, the browser successively indents nested list items, and the content in those items is justified to the innermost indented margin.
Directory and menu lists are another matter. They are lists of short items like a single word or simple text blurb and nothing else. Consequently, <li> items within <dir> and <menu> tags may not contain other lists or other block elements, including paragraphs, preformatted blocks, or forms.
Clean documents, fully compliant with the HTML standard, should not contain any text or other document item inside the unordered, ordered, directory, or menu lists that is not contained within an <li> tag. Most browsers are tolerant of violations to this rule, but then you can't hold the browser responsible for compliant rendering for exceptional cases, either.
Just as Netscape and Internet Explorer let you can change the bullet or numbering style for all of the items in an unordered or ordered list, they also let you change the style for individual items within those lists. With ordered lists, you can also 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.
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 7.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 7-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> <-- 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 extension in Netscape and Internet Explorer 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, as shown rendered by Netscape in Figure 7-5:
<ol> <li>Item number 1 <li>And the second <li value=9> Jump to number 9 <li>And continue with 10... </ol>