Syntax | <dl>...</dl> |
---|---|
Attribute Specifications |
|
Contents | One or more dt or dd elements |
Contained in | applet, blockquote, body, button, center, dd, del, div, fieldset, form, iframe, ins, li, map, noframes, noscript, object, td, th |
The dl element defines a definition list. An entry in the list is created using the dt element for the term being defined and the dd element for the definition of the term.
A definition list can have multiple terms for a given definition as well as multiple definitions for a given term. Authors can also give a term without a corresponding definition, and vice versa, but such a structure rarely makes sense.
An example follows:
<dl>
<dt>Block-level elements</dt>
<dd>
<p>
In XHTML, block-level elements may generally contain
inline elements and other block-level elements. They are
usually formatted differently than inline elements,
typically on a new line in visual browsers.
</p>
</dd>
<dt>Inline elements</dt>
<dt>Text-level elements</dt>
<dd>
<p>
Inline (or text-level) elements generally only contain
character data and other inline elements.
</p>
</dd>
</dl>
The dl element can be adapted for use with structures that are not strict terms and definitions, a practice that is justified when other XHTML elements cannot adequately describe a structure. Some examples follow:
<h1>community calendar</h1>
<dl class="calendar">
<dt>March 8</dt>
<dd>
The Symphony Orchestra presents <cite>A Rising Star</cite>
at the Anderson Center. Call 555-1234 for details.
</dd>
<dt>March 10</dt>
<dd>
Bereaved Families Support Night, 7:00 to 9:00 at
523 Main <abbr title="Street">St.</abbr>
</dd>
</dl>
<dl class="play">
<dt>brutus</dt>
<dd class="role Brutus">
<p>
I kiss thy hand, but not in flattery, Caesar;<br />
Desiring thee that Publius Cimber may<br />
Have an immediate freedom of repeal.
</p>
</dd>
<dt>caesar</dt>
<dd class="role Caesar">
<p>
What, Brutus!
</p>
</dd>
<dt>cassius</dt>
<dd class="role Cassius">
<p>
Pardon, Caesar; Caesar, pardon:<br />
As low as to thy foot doth Cassius fall,<br />
To beg enfranchisement for Publius Cimber.
</p>
</dd>
</dl>
Note the use of the class attribute in the preceding examples. This allows the author to easily suggest, through style sheets, a distinguishing presentation for different kinds of definition lists.
In addition to the common attributes shared by most elements, dl takes a compact attribute. This attribute, deprecated in XHTML 1.0 and poorly supported among browsers, suggests that visual browsers render the list compactly, perhaps with reduced spacing between items.