Good accessibility usually starts with clear words and the right HTML elements, not a large amount of extra code.
What You Need to Know
Radio buttons and related checkboxes ask one question with several possible answers. Fieldset wraps the group, while legend states that shared question so it is announced consistently.
Try the Example
Take a look at the example. We’ll explain the important lines right below it.
<fieldset>
<legend>Choose a snack</legend>
<label><input type="radio" name="snack" value="apple"> Apple</label>
<label><input type="radio" name="snack" value="banana"> Banana</label>
</fieldset>
Let’s Read the Code
- <fieldset>: The fieldset keeps related choices together.
- <legend>: The legend names a fieldset question.
- type: Type changes what sort of control or resource the browser uses.
- name: The name is the key used for the submitted value.
Read the named elements and attributes together. They explain how the browser connects this feature to the rest of the page.
What Happens in the Browser?
Try this with Tab and Shift+Tab. If you can, inspect the accessibility tree too; appearance alone does not tell the whole story.
Try a different way of reading. Read only the headings and labels, or navigate through links without looking at the rest of the page. If the page still makes sense, the underlying HTML is probably doing an important part of its job.
Your Turn
Use Tab and Shift+Tab to visit the controls, then read their labels aloud. Is the purpose of each one clear?
Common Beginner Mistakes
- Judging the page only by how it looks, without checking its meaning and keyboard behavior.
- Check the same result using both the browser and a keyboard, not only by looking at the screen.
Key Takeaways
- Radio buttons and related checkboxes ask one question with several possible answers.
- <fieldset>: The fieldset keeps related choices together.
- Remember that HTML form rules help the visitor, but server-side code must decide whether received data is valid.