This section is normative.
As its name suggests, the List Module provides list-oriented elements. Specifically, the List Module supports the following elements and attributes:
|Elements||Attributes||Minimal Content Model|
|dl||Common||(dt | dd)+|
|dt||Common||(PCDATA | Inline)*|
|dd||Common||(PCDATA | Flow)*|
|label||Common||(PCDATA | Inline)*|
|nl||Common||label , li+|
|li||Common||(PCDATA | Flow)*|
This module also defines the content set List with the minimal content model (dl | nl | ol | ul)+ and adds this set to the Flow content set of the Block Text Module.
Implementation: RELAX NG
XHTML offers authors several mechanisms for specifying lists of information. All lists must contain one or more list elements. Lists may contain:
The previous list, for example, is an unordered list, created with the ul element:
<ul> <li>Unordered information. </li> <li>Ordered information. </li> <li>Navigation information. </li> <li>Definitions. </li> </ul>
An ordered list, created using the ol element, should contain information where order should be emphasized, as in a recipe:
Definition lists, created using the dl element, generally consist of a series of term/definition pairs (although definition lists may have other applications). Thus, when advertising a product, one might use a definition list:
defined in XHTML as:
<dl> <dt><strong>Lower cost</strong></dt> <dd>The new version of this product costs significantly less than the previous one!</dd> <dt><strong>Easier to use</strong></dt> <dd>We've changed the product so that it's much easier to use!</dd> <dt><strong>Safe for kids</strong></dt> <dd>You can leave your kids alone in a room with this product and they won't get hurt (not a guarantee).</dd> </dl>
Lists may also be nested and different list types may be used together, as in the following example, which is a definition list that contains an unordered list (the ingredients) and an ordered list (the procedure):
The exact presentation of the three list types depends on the user agent and/or the stylesheet in effect. Authors must not use lists purely as a means of indenting text. This is a stylistic issue and is properly handled by style sheets.
Definition lists vary only slightly from other types of lists in that list items consist of two parts: a term and a description. The term is given by the dt element and is restricted to inline content. The description is given with a dd element that contains block-level content.
Here is an example:
<dl> <dt>Dweeb</dt> <dd>young excitable person who may mature into a <em>Nerd</em> or <em>Geek</em></dd> <dt>Hacker</dt> <dd>a clever programmer</dd> <dt>Nerd</dt> <dd>technically bright but socially inept person</dd> </dl>
Here is an example with multiple terms and descriptions:
<dl> <dt>Center</dt> <dt>Centre</dt> <dd> A point equidistant from all points on the surface of a sphere.</dd> <dd> In some field sports, the player who holds the middle position on the field, court, or forward line.</dd> </dl>
Another application of dl, for example, is for marking up dialogues, with each dt naming a speaker, and each dd containing his or her words.
Navigation lists are intended to be used to define collections of selectable items for presentation in a "navigation" menu. A navigation list is required to start with a label element that defines the label for the list.
On visual user agents, the default presentation behavior is as follows:
It is possible to change this default behavior through the use of style sheets. The behavior of navigation lists in non-visual user agents is unspecified.
This example illustrates the basic structure of a nested navigation list:
<nl> <label>Contents </label> <li href="#introduction">Introduction</li> <li> <nl> <label>Terms</label> <li href="#may">May</li> <li href="#must">Must</li> <li href="#should">Should</li> </nl> </li> <li href="#conformance">Conformance</li> <li href="#references">References</li> ... </nl>
Ordered and unordered lists are rendered in an identical manner except that visual user agents number ordered list items. User agents may present those numbers in a variety of ways. Unordered list items are not numbered.
Both types of lists are made up of sequences of list items defined by the li element.
This example illustrates the basic structure of a list.
<ul> <li> ... first list item...</li> <li> ... second list item...</li> ... </ul>
The li element defines a list item within an ordered, unordered, or navigation list. When the href attribute is defined, the contents of the list item become a selectable link, just as an a element with an href attribute would be.
The label element is used to define a label for an nl navigation list. The contents of the label element are displayed as the title of a list (or sublist). See nl for more information.