I wish HTML could do something semantically equivalent to this;
<dl class="main-list">
<definitionitem>
<dt>Some Thing</dt>
<dd>You know it!</dd>
<dt>Another Thing</dt>
<dd>Word.</dd>
</definitionitem>
<definitionitem>
<dt>Stuff</dt>
<dd>Alright!</dd>
</definitionitem>
</dl>
However, since the closest I've come is something I'm not 100% satisfied with the semantics of;
<div class="redundant-wrapper">
<dl class="main-list">
<dt>Some Thing</dt>
<dd>You know it!</dd>
<dt>Another Thing</dt>
<dd>Word.</dd>
</dl>
<dl class="another-main-list">
<dt>Stuff!</dt>
<dd>Alright!</dd>
</dl>
</div>
I was wondering if anyone has any other ideas of how you might do this?
Also, the reason the items would be grouped is because they are visually grouped in the content that is being marked up. Imagine a dictionary page, with a single definition list, where each definition is in an inset box that is floated left. I run into this situation all the time.
there's a repo about dd-dt wrapping. According to the html spec whatwg it is OK to wrap each dd & dt with div tag inside DL.
Here we are in 2018! CSS grid is well supported, and this offers yet another possible solution / workaround to the problem if the main goal is to control the positioning of the
dt
/dd
...HTML
CSS
(You can tweak the values of
grid-template-columns
to match your specific design requirements.)This doesn't "solve" the limitations of the spec, but I thought it helpful since you specifically mentioned concerns about semantic markup. As I mentioned above, there are limitations to what grid can do, but if the goal is to control the layout of the
dt
/dd
I think this might be the most semantic way to do it that is still valid HTML.No, Ian Hickson (HTML spec editor) is convinced that this is a CSS problem, not an HTML one:
At the same time, fantasai (CSS spec editor) is convinced in contrary:
Nevertheless, Ian apparently ignores that and continues to be detached from reality.
There are same problems with
LEGEND
(that must be first direct child ofFIELDSET
according to HTML spec),FIGCAPTION
(that must be first/last direct child ofFIGURE
), andLI
(direct child ofUL
/OL
).As for
DT
/DD
in particular, I personally useUL
list withDL
inside each ofLI
:So we have
DL
to make relation betweenDT
andDD
, andUL
list to make them all belong to one list.Update (2016-11-14): The HTML standard (WHATWG version for now) now (since 2016-10-31) allows the
DIV
element (optionally intermixed with so-called script-supporting elementsSCRIPT
,TEMPLATE
) to be direct children ofDL
elements. W3C’s HTML validator does not account for this change yet, but the experimental HTML5.org validator does.Update (2017-01-18): Turns out the spec does not allow more than one nested
DIV
wrapper forDT
/DD
, so usefulness of the feature in practice is actually very limited and theUL
→LI
→DL
approach described here is still relevant.