HTML <label> Tag

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The <label> element is a caption for a form control (such as <input>, <textarea>, or <select>).

Associate them with for matching the control’s id (explicit), or by wrapping the control inside the label (implicit). Clicking the label focuses or activates the control — a bigger, more accessible hit area.

Baseline · Widely available.

Not deprecated. Stable across browsers since about July 2015 (and much earlier in practice).

Tip.

Prefer explicit for/id for the most reliable assistive-tech support. Nesting plus for/id together is also fine.

HTML Syntax

syntax.html
<label for=" id">caption</label>

Both start and end tags are required. Do not nest another <label> inside. Only one labelable control should be associated with a given label.

Attributes

Element-specific attribute on <label>:

AttributeDescriptionTry it
forMatches the id of the labelable control in the same documentTry it

In the DOM, the matching IDL property is htmlFor (because for is a reserved word in JavaScript).

Global Attributes

The <label> tag also supports the Global Attributes in HTML.

Live Preview

Edit the caption text. Click the label — focus moves to the linked input via for/id.

for="demo-field" matches id="demo-field" on the input.

Associated field

<label for="demo-field">Email address</label>

HTML Examples

Explicit linking, implicit nesting, and a checkbox hit-area demo.

Example 1 — Explicit Label with for

Match for on the label to the control’s id.

HTML
<label for="email">Email:</label>
<input type="email" id="email" name="email">
Try It Yourself

How It Works

  1. Give the control a unique id (here, email).
  2. Set for on the label to that same value.
  3. Clicking the caption focuses the input.
  4. Screen readers can announce the label when the field is focused.

Example 2 — Implicit Label (Nesting)

Wrap the control inside the label — no for/id required for association.

HTML
<label>
  Username:
  <input type="text" name="username">
</label>
Try It Yourself

How It Works

  1. Put the input inside the <label> element.
  2. The browser links that nested control as the labeled control.
  3. Handy when you want caption and field kept together in markup.
  4. For max compatibility, you can still add matching for/id while nesting.

Example 3 — Checkbox with Larger Hit Area

Labels shine with checkboxes and radios — users can click the text, not only the tiny box.

HTML
<label for="terms">
  <input type="checkbox" id="terms" name="terms">
  I agree to the terms
</label>
Try It Yourself

How It Works

  1. Link with for/id (or nest the checkbox).
  2. Clicking the sentence toggles the checkbox.
  3. Keep links outside the label if you need a separate “read terms” link.
  4. Use the same pattern for radio groups with unique ids per option.

Edge Cases & Pitfalls

Most labeling bugs are mismatched ids or mixing interactive content inside the caption.

ids

for must match a unique id

Typos break the association. Duplicate ids in the page are invalid and unpredictable.

placeholder

Placeholder is not a label

Hints vanish while typing. Keep a visible <label> (or other durable accessible name).

interactive

No extra links/buttons inside

Avoid nesting <a> or extra buttons in the label — activation becomes confusing.

headings

Do not wrap headings in label

Headings are navigation landmarks. Style the label with CSS instead of putting <h1>–<h6> inside.

groups

Group titles use legend

For a set of related controls, use <fieldset> + <legend>, not a lone label for the whole group.

Browser Support

The <label> element is Baseline · Widely available. Support has been stable across major browsers since about July 2015.

✓ Baseline · Widely available

<label>

Supported in modern Chrome, Firefox, Safari, Edge, and Opera. Clicking an associated label focuses or activates the control.

100% Modern browser coverage
Google Chrome Yes
Supported
Mozilla Firefox Yes
Supported
Apple Safari Yes
Supported
Microsoft Edge Yes
Supported
Opera Yes
Supported
Internet Explorer Yes · EOL
Supported
<label> Widely available

Bottom line: Use <label> on every form control that needs a visible caption. Prefer explicit for/id association.

Key Takeaways

  • Role: <label> captions a form control and links to it programmatically.
  • Linking: use for/id (explicit) or wrap the control (implicit).
  • Benefit: better a11y announcements and a larger click/tap target.
  • Avoid: placeholder-only naming, nested labels, and interactive content inside labels.

One line: Every meaningful form control should have a clear, associated <label>.

Default CSS Settings

User-agent styles for label are minimal. A typical idea:

default.css
label {
  cursor: default;
}

Layout (block vs inline, spacing) is up to your stylesheet — often authors set display: block above fields.

Frequently Asked Questions

The label element provides a caption for a form control. Associating them helps assistive tech announce the purpose and lets users click the text to focus or activate the control.
Explicit: set for on the label to match the control’s id. Implicit: wrap the control inside the label. Prefer explicit for when you can; you can also nest and use for/id together.
No. Placeholder is a temporary hint and disappears when typing. Always provide a visible label (or another durable accessible name).
Yes. Several label elements can share the same for value matching one control id.
Labelable controls include button, input (except type=hidden), meter, output, progress, select, and textarea.
Avoid extra interactive content inside a label. It makes activation confusing. Put links near the control, not nested in the label text.

Next: legend

Caption a fieldset with the legend element.

legend tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful