×

html · level 2 · unit 2 · lesson 2

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

groups fields, and asks the question.

Radio buttons labelled Yes and No mean nothing on their own. Yes to what? Wrap them in a <fieldset> and the browser draws a box around the group.

The first thing inside a fieldset is its <legend>: the question the group answers. Screen readers say the legend with each choice, such as Need a high chair? Yes.

Use a fieldset for every set of radio buttons or checkboxes, and for any fields that belong together, like the lines of a postal address.

<form>
  <fieldset>
    <legend>Need a high chair?</legend>
    <input type="radio" id="chair-yes" name="chair" value="yes">
    <label for="chair-yes">Yes</label>
    <input type="radio" id="chair-no" name="chair" value="no">
    <label for="chair-no">No</label>
  </fieldset>
</form>

Press show my page to see it here.

A form can hold several fieldsets, one for each set of questions.