Relationships
Visual relationships between form elements should also be made programmatically, so that screen reader users get the same experience.
Form fields that have a label and input pairing will have a for
and id
attribute on each of those elements, but sometimes groupings can be more complex.
Hint/help text
Fieldsets with hint/help text
With fieldsets, the aria-describedby
attribute will normally be added to the <fieldset>
tag if it applies to all options in the set.
It’s still fine to add hint text on individual radio options though.
Sometimes it’s necessary to provide hint text on both the group and the input itself:
Note adding the aria-describedby
attribute to the <fieldset>
would be more efficient than adding a second value to the <input>
elements’ aria-describedby
attributes. Unfortunately screen readers usually override, rather than add to this with the more specific aria-describedby
attributes on the <input>
elements.