Lesson 16 / 28

Labels & Fieldsets

Making forms accessible and organized.

label for + fieldset

<label for> matches an input's id; <fieldset> with <legend> groups related fields.

<fieldset>
  <legend>Contact Info</legend>
  <label for="email">Email</label>
  <input id="email" type="email" name="email">
</fieldset>

Why label matters

A proper <label> lets screen readers announce the field and lets users click the text to focus the input — not just cosmetic.