Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Group `dt` and `dd` in `span` under `dl`

I'm trying to show or hide certain dt/dd groups within a dl. Is this valid HTML? Should browsers complain about this or is it legit? I've looked at the dl specs but couldn't find anything saying that the dl can contain something other than dt and dd children. I need to do this as I'm using angularJS which provides this neat way of adding or removing elements from the DOM

<dl>
  <dt>Term</dt>
  <dd>Definition</dd>

  <span ng-if="true">
    <dt>Term 2</dt>
    <dd>Definition 2</dd>
  </span>
</dl>
like image 541
Oktav Avatar asked Oct 30 '25 00:10

Oktav


1 Answers

Grouping with div in dl is now valid per WHATWG HTML, see https://html.spec.whatwg.org/multipage/semantics.html#the-dl-element

The dl element

Content model:

Either: Zero or more groups each consisting of one or more dt elements followed by one or more dd elements, optionally intermixed with script-supporting elements.

Or: One or more div elements, optionally intermixed with script-supporting elements.

<dl>
 <div>
  <dt> Last modified time </dt>
  <dd> 2004-12-23T23:33Z </dd>
 </div>
 <div>
  <dt> Recommended update interval </dt>
  <dd> 60s </dd>
 </div>
 <div>
  <dt> Authors </dt>
  <dt> Editors </dt>
  <dd> Robert Rothman </dd>
  <dd> Daniel Jackson </dd>
 </div>
</dl>
like image 72
zcorpan Avatar answered Oct 31 '25 16:10

zcorpan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!