Form label association

Actually wiring a label to its input (for + id) so screen readers name the field and clicking the text focuses it.

connecting the text to the boxlabel that belongs to the fieldlabel for htmlForclicking the label should focus the inputlinking label to inputform label assosiationscreen reader says 'edit text' with no namewhy is my input unlabeled

See it

Live demo coming soon

What it is

Text sitting next to an input is not a label. Association is the actual wiring: a label element whose for attribute (htmlFor in React) matches the input's id, or a label element wrapped around the input. Do it and the screen reader announces 'Email, edit text' instead of a nameless box, clicking the word focuses the field, and the tap target grows to include the text.

Every data-entry control (input, select, textarea, checkbox, radio) needs an accessible name from somewhere, and a real label is the best source. Two things sit outside the rule: a hidden input has no interface to label, and button-like inputs (submit, reset, button) take their name from the value attribute instead. Radio and checkbox groups need a second layer: wrap them in a fieldset with a legend so the group question ('Shipping speed') is announced along with each option. Helper text and error text attach separately via aria-describedby, not by being crammed into the label.

The everyday failure is the placeholder-as-label pattern. Placeholders vanish the moment someone types, usually fail contrast, and are ignored or read inconsistently by assistive tech, so the user who most needs the reminder loses it. If the design refuses a visible label, use a visually hidden label or aria-label, but keep the visible one whenever you can. Also: if the visible text says 'Email address', the accessible name should start with those same words, or voice control users cannot say the field's name to reach it.

Ask AI for it

Fix the labeling on this form. Give every data-entry control (input, select, textarea, checkbox, radio) a real label element wired to it: 'for' matching the input's 'id' in plain HTML, or 'htmlFor' with a stable generated id in React. Leave hidden inputs alone, and let submit, reset, and button inputs take their name from their value rather than bolting a label onto them. Group related radios and checkboxes in a fieldset with a legend. Move helper and error text into separate elements referenced with aria-describedby, and mark invalid fields with aria-invalid. Remove any placeholder that is doing a label's job: keep a visible label, or use a visually hidden label if the design demands it.

You might have meant

accessible namearia labelvisually hiddenerror identificationsemantic html

Go deeper