forms

<label>

Associates a caption with a form control so clicking the label focuses the input and screen readers announce it. Use one for every input, select, and textarea.

<label for="email">Email</label><input id="email" type="email">

Common attributes

Attribute Purpose
for id of the control this label describes
form id of the form the label belongs to
class Styling hook
id Unique identifier

Examples

<label for="email">Email</label><input id="email" type="email">

Explicit association via for/id

<label>Email <input type="email" name="email"></label>

Implicit association by wrapping

<label for="agree"><input type="checkbox" id="agree"> I agree</label>

Checkbox with clickable label text

Gotcha

The for attribute must match the input's id, not its name. A single

Related tags

← All HTML tags · CSS selectors · HTML entities