Back to HTML

Labels: Why Every Input Needs One

Coding Tutorials Team 30 June 2026

Every form control needs an accessible name, and the label element is how that is normally provided. It is a small element doing several jobs simultaneously, and skipping it breaks a form in ways that are invisible to the person who built it.

The explicit association

The usual approach connects a label to a control by matching the label's for attribute to the control's id.

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

The for attribute references an id, never a name. This catches people out because inputs usually carry both attributes with the same value, so a mistake here often works by accident and then fails on the one field where they differ.

Each id must be unique on the page. Repeating one across a form means every label points at the same field, and the association silently fails for the rest.

The implicit association

Wrapping the control inside the label associates them without any attributes.

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

This is convenient and avoids inventing ids. It is slightly less flexible for layout, since the two elements must be nested, and support in older assistive technology was historically weaker, which is why many style guides still prefer the explicit form. Either is valid, and consistency across a project matters more than which one you pick.

What a label actually gives you

Three things, and they benefit different people.

A screen reader announces the label when the field receives focus, so the user knows what to type. Without one, they hear only that there is a text field, which is a dead end.

Clicking the label moves focus to the control. For a checkbox or radio button this enlarges the target from a tiny square to the whole phrase, which is a meaningful improvement on a touchscreen and for anyone with limited motor control.

And the label remains visible once the field has content, which is precisely where placeholder text fails.

A placeholder is not a label

Using placeholder text as the only field description is the most common form mistake on the web. It looks clean and it fails on several counts.

The text disappears as soon as the user types, so anyone who is interrupted has no way to recall what the field was for without clearing it. The default contrast is low, often below accessibility thresholds, and darkening it makes the field look filled in. Support in assistive technology is inconsistent, with some software ignoring it entirely. And a field showing grey text is easily mistaken for one that already has a value, so people skip it.

Placeholders are useful for an example of the expected format, sitting alongside a real label rather than replacing it.

When there is no visible label

Some designs genuinely have no room for one, a search field with a magnifying glass icon being the usual case. There are two acceptable approaches.

The better one keeps a real label in the markup and hides it visually with CSS that moves it out of view without removing it from the accessibility tree. Using display none or visibility hidden removes it from both, which defeats the purpose.

The alternative is an aria-label attribute on the control. This works, with one caveat: voice control users say the words they can see, and if the accessible name differs from any visible text, the command fails. Where visible text exists, matching it is important.

Grouped controls need more

A set of radio buttons has a label on each option, and the question they answer needs a name too. That is what fieldset and legend provide, and without them a screen reader announces each option with no indication of what is being asked.

Required fields and their markers

An asterisk beside a label is the established convention for a required field, and on its own it communicates nothing to a screen reader beyond a stray punctuation character. The required attribute on the control is what actually conveys the requirement, and it should always be present when a field is mandatory.

A legend somewhere on the form explaining what the asterisk means is worth including, since the convention is familiar to most people and not universal. Marking optional fields instead is a reasonable alternative on forms where most fields are required.

Write the text well

Labels should be short, specific and phrased as what the field wants rather than as an instruction. Avoid putting formatting requirements in the label itself, since they will be announced every time the field is focused. Put those in supplementary text associated with a describedby attribute, which is announced after the label rather than as part of it.