Semantic implications of multiple
tags

后端 未结 2 1499
旧巷少年郎
旧巷少年郎 2021-01-12 13:28

When using

lists to associate keys to values, is there a semantic difference between these 2 samples? Which one provides better semantics? What do multiple
相关标签:
2条回答
  • 2021-01-12 13:47

    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.

    0 讨论(0)
  • 2021-01-12 13:57

    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.

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题