Skip to content

.tip

· one of the small things

A radio group needs a fieldset and a legend

Every radio has a label, but the question they answer sits in a heading above them. A screen reader says "Standard, radio button, 1 of 3" and never what is being chosen.

<fieldset>
  <legend>Shipping speed</legend>
  <label><input type="radio" name="speed" value="standard" /> Standard</label>
  <label><input type="radio" name="speed" value="express" /> Express</label>
</fieldset>

The legend becomes the group's accessible name and is read with each option, so the question comes with the answers. Related checkboxes want the same. Style the default border away, keep the elements.

accessibilityfrontend