What is the label tag?

<label> gives a form control its accessible name and visible caption. Screen readers read the label when the control is focused, and clicking the label focuses the input or toggles the checkbox or radio, which makes small controls easier to hit. Connect it with for matching the control's id, or by wrapping the control inside the label.

Two ways to associate

  • Explicit: <label for="email">Email</label> <input id="email">.
  • Implicit: <label>Email <input></label>. Both work; explicit labels are more flexible for layout.

Why placeholders are not labels

Placeholder text disappears when typing, often has low contrast, and is not reliably announced. Always use a real label (it can be visually hidden with a .sr-only class if the design requires).

Groups

Radio buttons and checkbox groups need a group label: <fieldset> with a <legend> ("Shipping method"), and each option has its own <label>.

Other ways to name controls

  • aria-label: when no visible text exists (icon-only buttons).
  • aria-labelledby: point to existing visible text. Prefer a visible <label> for form fields.

Extra help text

Connect hints and error messages with aria-describedby, so they are read after the label.

Rules

  • One label per control (multiple labels are allowed but confusing).
  • Do not put interactive elements (links, buttons) inside a label.
  • Labels should describe the field, not repeat instructions.

Standards

WCAG 1.3.1 (Info and Relationships), 3.3.2 (Labels or Instructions) and 4.1.2 (Name, Role, Value).

Code example

html
1<style>
2 body { font-family: system-ui; }
3 .field { display: grid; gap: 4px; margin-bottom: 12px; max-width: 300px; }
4 .hint { color: #64748b; font-size: 13px; }
5 .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
6</style>
7
8<div class="field">
9 <label for="email">Email address</label>
10 <input id="email" type="email" aria-describedby="email-hint" autocomplete="email">
11 <span id="email-hint" class="hint">We'll send a confirmation link.</span>
12</div>
13
14<!-- Implicit association + larger click target -->
15<label><input type="checkbox" name="news"> Send me product updates</label>
16
17<fieldset>
18 <legend>Shipping method</legend>
19 <label><input type="radio" name="ship" value="std" checked> Standard (free)</label><br>
20 <label><input type="radio" name="ship" value="exp"> Express ($9)</label>
21</fieldset>
22
23<!-- Visually hidden label for a compact search box -->
24<label for="q" class="sr-only">Search articles</label>
25<input id="q" type="search" placeholder="Search…">

Practice this question

Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the HTML & CSS set.

Open in study app