<label> Tag in HTML

Quick facts

CategoryFlow content, phrasing content, interactive content, palpable content
Content modelPhrasing content, but no other <label> and no labelable control other than the one it labels
Tag omissionNeither the start nor the end tag can be omitted
Permitted parentsAny element that accepts phrasing content (usually inside a <form>)
DOM interfaceHTMLLabelElement

Syntax

<label for="email">Email</label> <input type="email" id="email" name="email"> <label><input type="checkbox" name="news"> Send me news</label>

Live example

Edit the code below and watch the preview update instantly.

index.html
Preview

Attributes

AttributeDescription
forThe id of the form control this label belongs to. Not needed if the control is inside the label.

Common examples

A label linked with for and id

The label’s for matches the field’s id. Clicking the label now focuses the field.

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

A bigger click target for checkboxes

Wrapping a checkbox in its label makes the whole text clickable — much easier to hit on a phone.

<label> <input type="checkbox" name="terms" required> I agree to the terms </label>

A label that is hidden on screen

A search box next to a magnifying-glass button may not need visible text, but screen readers still need a label. Hide it visually instead of removing it.

<label for="q" class="visually-hidden">Search the site</label> <input type="search" id="q" name="q"> <style> .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } </style>

Marking required fields

Add a visual marker to the label and the required attribute to the field. Explain what the asterisk means once at the top of the form.

<p>Fields marked * are required.</p> <label for="name">Name <span aria-hidden="true">*</span></label> <input id="name" name="name" required>

<label> vs aria-label

Both give a form field a name that screen readers announce, but a <label> is visible text on the page while aria-label is an invisible attribute. A visible label helps everyone: sighted users know what to type, the click target gets bigger, and people using voice control can say “click Email” because they can see the word.

Use aria-label only where visible text truly doesn’t fit, such as an icon-only button. Even then, a visually hidden <label> is often just as easy and works in more situations.

<label>aria-label
Visible on pageYesNo
Clicking focuses the fieldYesNo
Best forEvery form fieldIcon-only buttons

Common mistakes to avoid

  • for that doesn’t match an id. A typo breaks the link silently. The for value must exactly match the field’s id, including capital letters.
  • One label for several fields. Each field needs its own label; for a group such as a date split into day, month and year, use a <fieldset> with a <legend>.
  • Empty or vague labels. “Field 1” or a lone “*” tells nobody what to type.
  • Duplicate ids. If two fields share an id, both labels point at the first one and the second field is left unnamed.

Accessibility & SEO tips

  • Labels enlarge the clickable area of small controls like checkboxes and radio buttons, which helps people with shaky hands and touch screens.
  • Keep label text short and specific (“Work email”, “Phone number”), and put extra help in a hint linked with aria-describedby.
  • Only hide labels when the field’s purpose is obvious from its surroundings, such as a search box next to a “Search” button.

Browser support

Supported in every browser, including Chrome, Edge, Firefox, Safari and their mobile versions — it has been part of HTML since the very first versions.

Related tags

Frequently asked questions

Should I use the for attribute or wrap the input inside the label?
Both work. The for attribute (matching the input's id) gives you more freedom in layout; wrapping avoids needing an id. Using for together with an id is the most reliable choice across assistive technologies.
Can I use a placeholder instead of a label?
No. Placeholder text disappears as soon as someone starts typing, has low contrast, and isn't reliably read as a name. Always add a real <label>; a placeholder can show an example on top.
Why do labels matter for accessibility?
Screen readers announce the label when a field gets focus, so users know what to type. Labels also make small targets like checkboxes and radio buttons easier to click or tap.
Can one input have two labels?
Yes, more than one <label> can point at the same field, and screen readers read them all. It's rarely needed: one clear label plus a hint linked with aria-describedby is usually better.
Can a label contain a link?
Yes, for example "I agree to the terms" with a link on "terms". Keep the link short, because clicking anywhere else on the label still toggles the checkbox.
How do I style the label of a checked checkbox?
Put the checkbox before the label and use input:checked + label in CSS, or style the wrapping label with label:has(input:checked) in modern browsers.