This is incorrect:
1. <dl> has no corresponding (viz. implicit) role, but can be given the role group, list, none or presentation <https://w3c.github.io/html-aria/#el-dl>.
2. You’re only allowed to define aria-label on elements that have a compatible role, implicit or explicit <https://w3c.github.io/html-aria/#docconformance-naming>.
3. aria-label is allowed on all but a handful of roles <https://www.w3.org/TR/wai-aria-1.2/#aria-label>, which in this case knocks out presentation and none, leaving group and list.
4. group doesn’t feel right, list feels acceptable.
In summary: either ditch the aria-label, or add role="list" (meaning also role="listitem" on children).
—⁂—
One thing the article misses is that you can have multiple <dt> in a row too, not just <dd>. The spec has a good example: https://html.spec.whatwg.org/multipage/grouping-content.html...
They’re not name–value pairs, they’re name–value groups.
https://info.cern.ch/hypertext/WWW/TheProject.html
https://info.cern.ch/ (A landing page of sorts to give context and orientation about the actual first website.)
TIL I’ve been naming it wrong for a decade.
Nearly two!
<tr>
<td> first
<td> second
<tr>
<td> what
<td> ever
I find it simpler and cleaner than any of the markdown table markups <table><tr><th>Term 1<td>Definition 1
<tr><th>Term 2<td>Definition 2
</table>
<dl><dt>Term 1<dd>Definition 1
<dt>Term 2<dd>Definition 2
</dl>but then you can always use HTML tables in markdown and Pandoc transforms it just fine
I.e. can we do
<dl>
<dt>Actions</dt>
<dd><dl>...</dl></dd>
</dl>https://html.spec.whatwg.org/#the-dd-element
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...
[1] https://validator.w3.org/nu/?showsource=yes&showoutline=yes&...
And... it also uses the wrapper div for styling
I dunno, I guess I’m a caveman. If it looks right and works (including accessibility) then I figure I’m pursuing something that doesn’t matter a lot.
> Description list support continues to be generally good (with VoiceOver still the outlier), even if you may not like how it is supported.
You shouldn't try to fix this kind of thing by mangling the HTML, since (1) users tend to be used to their screen reader's quirks, and (2) in situations like these, making it juuuust right in one screen reader is likely to make it incomprehensible in another. But it is important to be aware of these quirks, so you don't accidentally design an interface that relies on less-quirky behaviour.
Wait what? <DL> has been in HTML since.. the first draft in 1993!
I like DL's but they can be challenging to style. This article is using a lot of fixed pixel widths which would break on really small screens or larger data.
Some of the extracted CSS chunks
#statblock{
box-shadow:0 20px 25px -5px rgba(0,0,0,.1),0 10px 10px -5px rgba(0,0,0,.04);
font-family:Lato,'Trebuchet MS',sans-serif;
font-size:85%;
min-width:50ch;
max-width:70ch;
margin-inline:auto;
background-color:#fffaf0;
padding-inline:2rem;
padding-block:1rem
}
dl.statblock-bio{
color:maroon;
line-height:1.5;
border-top:5px solid maroon;
border-bottom:5px solid maroon;
margin-block:0.75em;
padding-block:0.75em
}
dl.ability-scores{
min-width:40ch;
display:flex;
justify-content:space-around;
color:maroon
}
dl.ability-scores>div{
text-align:center;
line-height:1.5
}
dl.ability-scores dt{
font-weight:700
}https://html.spec.whatwg.org/multipage/grouping-content.html...
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/...
EDIT everyone replied at once lol. I'm surprised too about div.
Also, screen reader support: https://a11ysupport.io/tech/html/dl_element
<my-element> != <div>
[1] https://developer.mozilla.org/en-US/docs/Web/API/Web_compone...
[2] https://developer.mozilla.org/en-US/docs/Web/API/HTMLDivElem...
Somehow, people got convinced that <div> elements are evil and should never be used no matter what. Yes, you should use a more semantic element when it makes sense, but try to remember what that phrase actually means.
Why is it preferred over <table> for laying out columns via a the character attributes at the bottom of TFA?