Reputation: 52531
When using <dl>
lists to associate keys to values, is there a semantic difference between these 2 samples? Which one provides better semantics? What do multiple <dd>
tags imply in this context?
Sample 1: Multiple <dd>
items.
<dl>
<dt>Authors</dt>
<dd>John Lennon</dd>
<dd>Paul McCartney</dd>
<dt>Genres</dt>
<dd>Pop</dd>
<dd>Rock</dd>
</dl>
Fangs output:
Definition list of two items Authors equals John Lennon equals Paul McCartney Genres equals Pop equals Rock List end
Sample 2: Single <dd>
contains <ul>
<dl>
<dt>Authors</dt>
<dd>
<ul>
<li>John Lennon</li>
<li>Paul McCartney</li>
</ul>
</dd>
<dt>Genres</dt>
<dd>
<ul>
<li>Pop</li>
<li>Rock</li>
</ul>
</dd>
</dl>
Fangs output:
Definition list of two items Authors equals List of two items bullet John Lennon bullet Paul McCartney List end Genres equals List of two items bullet Pop bullet Rock List end List end
Upvotes: 10
Views: 6134
Reputation: 96607
The relevant part of the dl
definition is:
The values within a group are alternatives; multiple paragraphs forming part of the same value must all be given within the same dd element.
I think a clear example would be a dl
describing homonyms, e.g. "bank":
<dl>
<dt><dfn>bank</dfn></dt>
<dd>An institution where one can place and borrow money and take care of financial affairs.</dd>
<dd>An edge of river, lake, or other watercourse.</dd>
<dd>A row or panel of items stored or grouped together.</dd>
</dl>
↑ Here the term "bank" (dt
) has three meanings (dd
). Using one dd
with a ul
wouldn’t hold the same semantics:
<dl>
<dt><dfn>bank</dfn></dt>
<dd>
<ul>
<li>An institution where one can place and borrow money and take care of financial affairs.</li>
<li>An edge of river, lake, or other watercourse.</li>
<li>A row or panel of items stored or grouped together.</li>
</ul>
</dd>
</dl>
↑ Here the term "bank" would have only one meaning (and this meaning consists of or is described by a ul
).
Coming back to your author example, you’d typically want to use the first variant (as described by BoltClock), because each author really is a "value" (dd
) in the group of authors.
However, in the end it depends on your content and, more importantly, on your understanding of that content.
Upvotes: 11
Reputation: 723759
The document that you link to contains the following example:
In the following example, one entry ("Authors") is linked to two values ("John" and "Luke").
<dl> <dt> Authors <dd> John <dd> Luke <dt> Editor <dd> Frank </dl>
In other words, the two <dd>
elements following a single <dt>
element are both associated to that same <dt>
element.
There doesn't appear to be much of a difference in terms of semantics, then, between having multiple successive <dd>
elements, and having a single <dd>
that in turn contains a <ul>
. If it's important to distinguish "a list" (a <ul>
in a single <dd>
) from "a group of values" (multiple <dd>
s in sequence), then I would decide based on that. If that's not important, then given a choice I would pick multiple <dd>
s in sequence, because it is simpler.
Upvotes: 11