Skip to main content
Albero Academy

Labels & Fieldsets

Make forms accessible with labels and grouping.

Forms7 min

A <label> names an input and — crucially — connects to it so the two work as one. <fieldset> groups related controls. Both are accessibility essentials.

Connecting labels

two ways to associate a label
<!-- for/id association -->
<label for="email">Email</label>
<input type="email" id="email" name="email" />
<!-- or wrap the input -->
<label>Email <input type="email" name="email" /></label>

Grouping with fieldset

fieldset and legend
<fieldset>
<legend>Contact preferences</legend>
<label><input type="checkbox" name="email_ok" /> Email me</label>
<label><input type="checkbox" name="sms_ok" /> Text me</label>
</fieldset>

Key takeaways

  1. 01A <label> names an input; connect it via for/id or by wrapping the input.
  2. 02Clicking a connected label focuses the input; screen readers announce it.
  3. 03A placeholder is not a label — it vanishes when typing.
  4. 04<fieldset> + <legend> group related controls (e.g. radio sets).

Finished this chapter?

Mark it complete to track your progress through HTML.