Here's the scenario:
If it was all text then I would use all dl tags. However, there are some input, checkboxes, dropdown list. Is it semantics to use dt and dd? If not, what tag is the most appropriate?
Thank you
Here's the scenario:
If it was all text then I would use all dl tags. However, there are some input, checkboxes, dropdown list. Is it semantics to use dt and dd? If not, what tag is the most appropriate?
Thank you
The content model of dl
elements is
Zero or more groups each consisting of one or more
dt
elements followed by one or moredd
elements, optionally intermixed with script-supporting elements.
The content model of dt
elements is
Flow content, but with no
header
,footer
, sectioning content, or heading content descendants.
The content model of dd
elements is
Flow content includes input
and select
elements (among others).
So yes, it's allowed.
With semantics there can be a lot of grey areas and often it can come down to interpretation. Strictly speaking you don't have a list of definitions, but it could be interpreted that way.
One option you can look at is a straight list:
<ul class="meaninfulClassNameHere">
<li>
<span class="label">Blah</span><span class="value">Blah<span>
</li>
<li>
<label for="someInputID" class="label">A Label</label>
<span class="value">
<select id="someInputID></select>
</li>
</ul>
It may also be more flexible than a dl
UPDATE
However having just read: http://html5doctor.com/the-dl-element/, in HTML5 dl
is a Description List. It quotes the W3C spec:
The dl element represents an association list consisting of zero or more name-value groups (a description list). A name-value group consists of one or more names (dt elements) followed by one or more values (dd elements), ignoring any nodes other than dt and dd elements. Within a single dl element, there should not be more than one dt element for each name.
Name-value groups may be terms and definitions, metadata topics and values, questions and answers, or any other groups of name-value data.
And what you have is effectively Name/Value pairs, even though some of the data it represented in an input.
Just remember you can also put a label
in a dt
` is semantically appropriate.