J.9. Nested and Ordered Lists

Lists may be nested to represent hierarchical relationships, as in an outline format. Figure J.9 demonstrates nested lists and ordered lists (i.e., list that order items by letter or number).

Figure J.9. Nested and ordered lists in XHTML.

(This item is displayed on pages 1341 - 1343 in the print version)

"http://www.w3.org/1999/xhtml"> 9 10

1 6 7 8

Advanced lists 11 12 13 14 15

The Best Features of the Internet

16 17 18

  • 19
    • You can meet new people from countries around 20 the world.
    • 21 22
      • 23 You have access to new media as it becomes public: 24 25 26 27
        • 28
          • New games
          • 29
            • 30 New applications 31 32 33
              1. "I"> 34
                • For business
                • 35
                  • For pleasure
                  • 36

              37 38

            • 39 40
              • Around the clock news
              • 41
                • Search engines
                • 42
                  • Shopping
                  • 43
                    • 44 Programming 45 46 47
                      1. "a"> 48
                        • XML
                        • 49
                          • Java
                          • 50
                            • XHTML
                            • 51
                              • Scripts
                              • 52
                                • New languages
                                • 53

                      54 55

                    • 56 57
                    58 59
                  • 60 61
                    • Links
                    • 62
                      • Keeping in touch with old friends
                      • 63
                        • It is the technology of the future!
                        • 64 65
                        66 67

                        My 3 Favorite CEOs

                        68 69 70 71

                        1. 72
                          • Lawrence J. Ellison
                          • 73
                            • Steve Jobs
                            • 74
                              • Michael Dell
                              • 75

                        76 77 78


The first ordered list begins in line 33. Attribute type specifies the sequence type (i.e., the set of numbers or letters used in the ordered list). In this case, setting type to "I" specifies upper-case roman numerals. Line 47 begins the second ordered list and sets attribute type to "a", specifying lowercase letters for the list items. The last ordered list (lines 7175) does not use attribute type. By default, the list's items are enumerated from one to three.

A Web browser indents each nested list to indicate a hierarchal relationship. By default, the items in the outermost unordered list (line 18) are preceded by discs. List items nested inside the unordered list of line 18 are preceded by circles. Although not demonstrated in this example, subsequent nested list items are preceded by squares. Unordered list items can be explicitly set to discs, circles or squares by setting the ul element's type attribute to "disc", "circle" or "square", respectively.

Категории