Search code examples
htmlxhtml

Valid html tag to group definition list items


I currently have:

<dl>

  <span class="wrapper">

    <dt>A title</dt>
    <dd>A description</dd>

  </span>

  <span class="wrapper">

    <dt>A title</dt>
    <dd>A description</dd>

  </span>

</dl>

This (or divs instead of spans) doesn't validate. Is there anything I could wrap it with that would?


Solution

  • No. A dl allows only two kinds of children: dt and dd. See this article for a longer explanation.

    In short: the reason why dt and dd aren't "grouped" is that you can have one or more dt elements per dd.

    If you really need to group, then your only option is to build the list manually using <ul>/<ol> with the necessary CSS.