Regarding making something like the following accessible, currently I have the following:
<div tabindex="0" aria-labelledby="key1" aria-describedby="value1">
<label id="key1">Current User:</label>
<span id="value1">BBRENNAN</span>
</div>
Is it necessary for this block to be focusable with tabindex="0"
? Or can screen readers infer this relationship more naturally? I understand screen readers can usually find and read text, but it's not clear to me how to ensure that I convey the relationship between Current User
and BBRENNAN
.
EDIT:
I was just looking into definition lists, which seem closer to what I need. You could also perhaps argue that this is tabular data, and should use a table. Totally fine if these solutions are indeed the best practices, but one thing I like about aria-labelledby
and aria-describedby
is that focusing the outer div reads the whole thing nicely in NVDA. So the above would read as "Current User, BBRENNAN."
Definition lists for some reason read as "List with 2 items, current user." Tables just let me use arrow keys to move the reader between cells, which also doesn't achieve what I describe above. Link for a 5 year old thread on this very topic: https://webaim.org/discussion/mail_thread?thread=7089