HTML and CSS Reference
In-Depth Information
their job titles, or a sequence of events and the dates on which they occurred were all common uses of
definition lists. HTML5 has formalized this real-world usage and redefined the definition list as a
description list
, suitable for any case where content calls for a listing of name-value groups. You can still
use a
dl
for a list of terms and definitions, of course.
The
dl
element is flow content, requires an end tag, and can only contain
dt
and
dd
elements as its
children. A single term may have several associated descriptions, or a single description may apply to
several terms grouped before it. The list is segmented wherever a
dt
immediately follows a
dd
, marking
the beginning of a new sequence of terms and descriptions.
Required Attributes
The
dl
element doesn't have any required attributes.
Optional Attributes
There are no optional attributes for the
dl
element.
dt
The
dt
element, which can only contain text and/or phrase elements, designates a term or item being
described. A description term (or sequence of terms) is associated with every description that follows it
until a new
dt
element appears to begin a new sequence, or until the list ends with a
</dl>
end tag. You
can omit the
</dt>
end tag if the element is immediately followed by another
dt
element or a
dd
element.
Required Attributes
There are no required attributes for the
dt
element.
Optional Attributes
The
dt
element doesn't offer any optional attributes.
dd
The
dd
element contains a description of the
dt
element (or elements) that immediately precedes it. In the
case of multiple descriptions for a single term, each one should be wrapped in its own
dd
element. The
dd
element is flow content and can contain text or other flow elements. If your description spans several
paragraphs, mark them up as paragraphs (
p
) in a single
dd
rather than as separate
dd
s—the entire
contents of one
dd
element should comprise one description. The
dd
's end tag is optional if the next
element is another
dd
, a
dt
, or if the next tag is a
</dl>
end tag.
Listing 4-24 shows the markup for a brief description list. In the example, the first term's description
consists of two paragraphs, whereas the second term has two distinct descriptions.