Grouping with fieldset in HTML
A fieldset groups related controls and its legend names the group.
<fieldset>
<legend>Delivery address</legend>
<label>
Street
<input type="text" name="street" autocomplete="address-line1">
</label>
<label for="postcode">Postcode</label>
<input type="text" id="postcode" name="postcode" inputmode="numeric">
</fieldset>
How it works
legendmust be the first child of thefieldset.- Wrapping an input inside its label needs no
forattribute. - Grouping is what screen readers announce before the fields.
The run, in numbers
- Lines
- 9
- Characters to type
- 252
- Tokens
- 61
- Three-star pace
- 65 tpm
At the three-star pace of 65 tokens a minute, this run takes about 56 seconds.
Step 4 of 5 in Fields & labels, step 7 of 25 in Forms & inputs.