← Back to context

Comment by lelandfe

3 days ago

> Like <label>, <output> has a for="" attribute. Here you list the ids of any <input> elements the result depends on

Any screen reader users able to comment on whether this is worth doing? I suspect this would be such a rarity online that screen reader users wouldn’t be familiar with it, but it depends on the UX of the software

Not a screen reader user but I have used them a lot in testing. I'd be surprised if it's meaningfully exposed to assistive tech. Not at the computer right now so I can't test.

That said, I imagine it's more useful to do the opposite, label the output itself e.g.

<label for="output">Total</label> <output id="output">£123.45</output>

That way it will be announced like "Total, £123.45" rather than a random number with no context

  • For static scenarios this works well with screen readers. On the output tag the "for" property helps screen readers deal with dynamic values, essentially adding reactivity to the element. I use it so infrequently I've never explored how it works but screen readers will catch that the value has been updated.

    This is handy for testing with screen readers, and includes links to the appropriate spec (for output and all elements):

    https://stevefaulkner.github.io/AT-browser-tests/test-files/...

    • It's often the case that screen readers do not support the more exotic aspects of html (hell even some basics, unfortunately).

      The browser may add a reference from one to the other in the accessibility tree, but whether a screenreader announces it is another matter. I'd be surprised if it's supported in any meaningful way here. Happy to be shown otherwise!