Semantic implications of multiple <dd> tags

心不动则不痛 提交于 2019-12-19 07:13:07

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/17705922/semantic-implications-of-multiple-dd-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!