It's for a definition list, which only allows dt
and dd
tags. It is not valid to wrap a dt
and its associated dd
inside of a div
.
Example definition list:
<dl>
<dt>Name:</dt>
<dd>Nick</dd>
<dt>Age:</dt>
<dd>26</dd>
<!-- etc -->
</dl>
I want the dt
and dd
tags to be inline-blocks that wrap. I want to allow up to two dt/dd
pairs on one line, but I never want it to wrap after a dt
tag. In other words, I never want "Name" and "Nick" to be on different lines. I never want "Age" and "26" to be on different lines either. Perhaps all four of them are on one line, or perhaps "Name" and "Nick" are on one line and "Age" and "26" are on the next line, depending on the viewport width.
I tried putting
between the elements but that didn't work. I can't wrap the dt with its associated dd because technically that is invalid markup.
Is there any correct solution to this problem? Or do I have to abandon semantic principles in order to get the styling I want?
Edit: This is not a duplicate of How to style dt and dd so they are on the same line? because I said "I want to allow up to two dt/dd pairs on one line". Whether there is one or two pairs depends on variable content.