HTML The Definitive Guide (83 page)

Read HTML The Definitive Guide Online

Authors: Chuck Musciano Bill Kennedy

BOOK: HTML The Definitive Guide
11.27Mb size Format: txt, pdf, ePub


8.2.1.2 The type attribute

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, you can use the type attribute with the

    tag to change the numbering style itself. With the
      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 8.1.)

      Table 8.1: HTML 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 this example:


      1. This is the Roman number 8.

      2. The numerals increment by 1.

      3. And so forth...


      The results are shown in
      Figure 8.3.

      Figure 8.3: The start and type attributes work in tandem

      The type and value of individual items in a list can be different from the list as a whole, as described
      in section Section 8.3.1, "Changing the Style and Sequence of Individual List Items".

      8.2.1.3 Compact ordered lists

      Like the unordered list, the ordered list in HTML has an optional compact attribute that is deprecated in the HTML 4.0 standard. Unless you absolutely need to use it, don't.

      8.2.1.4 The class, dir, id, lang, event, style, and title attributes
      These attributes are applicable as well with ordered lists and have identical effects as for unordered
      lists. [The class and style attributes, 8.1.1.3] [The lang and dir attributes, 8.1.1.4]
      [The id and title

      attributes, 8.1.1.5]
      [The event attributes, 8.1.1.6]

      8.1 Unordered Lists

      8.3 The

    1. Tag

      Chapter 8

      Formatted Lists

       

      8.3 The

    2. Tag

      It should be quite obvious to you by now that the

    3. tag defines an item in a list. It's the universal tag for HTML list items in ordered (
        ) and unordered (
          ) lists, as we discuss earlier, and for directories () and menus (), which we discuss in detail later in this chapter.


        • Function:

          Define an item within an ordered, unordered, directory, or menu list Attributes:

          CLASS ONMOUSEDOWN

          DIR ONMOUSEMOVE

          ID ONMOUSEOUT

          LANG ONMOUSEOVER

          ONCLICK ONMOUSEUP

          ONDBLCLICK STYLE

          ONKEYDOWN TITLE

          ONKEYPRESS TYPE

          ONKEYUP VALUE

          End tag:

        • ; usually omitted

          Contains:

          flow

          Used in:

          list_content

          Because the end of a list element can always be inferred by the surrounding document structure, most authors omit the ending tags for their list elements. That makes sense because it becomes easier to add, delete, and move elements around within a list. We recommend not using the end tag.

          Although universal in meaning, there are some differences and restrictions to the use of the

        • tag for each HTML list type. In unordered and ordered lists, what follows the
        • 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,

        • items within and 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

        • 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.

          8.3.1 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.

          8.3.1.1 The type attribute

          Acceptable values for the type attribute in the

        • 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.

          Once you use the type attribute to change the bullet or numbering, subsequent items adopt the bullet or numbering style. There is no way to revert back to the list's default type once you have changed the type for a single item.

          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:


          1. Changing the numbering style
          2. Doesn't alter the order!

          3. <-- See? It's a "c"!

          4. Uppercase Roman numerals!

          5. Lowercase Roman numerals!

          6. Plain ol' numbers!


          Figure 8.4: Changing the numbering style for each item in an ordered list

Other books

Last Rites by Kim Paffenroth
Wounded by Percival Everett
A Faraway Island by Annika Thor
Pursuit of a Kiss by Lola Drake
Loving Promises by Gail Gaymer Martin
Jump Start Your Marriage by Barry Franklin
The Source of Magic by Piers Anthony