Skip to content
Tutorials Center
My learning

Topics

HTML Reference ยท Forms

The <label> element

Reference for the HTML <label> element: connecting a caption to a form control with for or by nesting, bigger click targets, accessibility notes and technical details.

The <label> element is the caption for a form control. It tells sighted users what a field is for, gives the control its accessible name for screen readers, and makes the caption clickable: clicking a label focuses or toggles its control.

There are two ways to connect them. Point at the control's id with for, or put the control inside the label.

HTML
<label for="town">Town</label>
<input type="text" id="town" name="town">

<label><input type="checkbox" name="remember"> Remember me</label>

Try it

Explicit and implicit labels

Attributes

Attribute Values Description
for ID of a labelable element The control this label belongs to. The element must be labelable: <button>, <input> (not hidden), <meter>, <output>, <progress>, <select>, <textarea> or a form-associated custom element. Without for, the label applies to the first labelable element inside it.

It also accepts the global attributes.

Usage notes

  • Every visible control needs one. Placeholders, nearby text and title tooltips are not reliable substitutes. If the design truly has no visible caption, use aria-label, but a visible label is better for everyone.
  • for matches id, not name. A common mistake is for="email" on a field that only has name="email". The id must also be unique in the page.
  • Wrapping is fine, both is fine. Nesting the control inside the label works without for. Using both nesting and a matching for is also valid and helps some older assistive tools.
  • One control, several labels. A control can have more than one label (all are combined into its name), but each label labels exactly one control.
  • Bigger target. Clicking the label activates the control, which matters for small checkboxes and radio buttons on touch screens.
  • Keep links and buttons out. Interactive content inside a label (other than its control) makes clicking unpredictable. Put "read the terms" links next to the label instead.
  • Don't label a group. To caption a set of radio buttons or checkboxes as a whole, use <fieldset> and <legend>.

Technical summary

Content categories Flow content, phrasing content, interactive content, palpable content
Permitted content Phrasing content, but no labelable elements other than the labeled control, and no <label> descendants
Tag omission None; both the start and end tags are required
Permitted parents Any element that accepts phrasing content
Implicit ARIA role No corresponding role
DOM interface HTMLLabelElement
Default display inline

<label> is not itself form-associated: it has no form attribute and is never submitted.

Browser support

Supported in every browser.