Glossary / Form labels

Form labels

Form labels tell users what information a control expects and provide its accessible name. A properly associated HTML <label> is announced by assistive technology, enlarges the clickable area for many controls, supports voice input, and creates a visible relationship. Placeholder text is not a durable label: it disappears during entry, often has weak contrast, and may not be exposed consistently. Good forms pair labels with instructions, grouping, input purpose, and clear error feedback.

Labeling patterns

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

Validation and common failures

Mark required fields clearly in text and programmatically. On submit, preserve entered values, identify each error in text, associate it with its control, and explain how to fix it. Do not use placeholder as the only label, put unrelated text inside a label, duplicate IDs, or use title as the sole fallback. Visually hidden labels are useful when the visual context is unmistakable, but visible labels generally serve more users.

Interview questions

  1. Why not use placeholder as a label? It disappears, may have low contrast, and does not reliably provide persistent instructions or label behavior.
  2. How do you associate a label? Use a <label for> matching a unique control id, or wrap the control in the label.
  3. How do you label a radio group? Group related inputs in a <fieldset> with a meaningful <legend> and label each option individually.
  4. When use aria-describedby? For supplemental instructions or error text, not as a substitute for the control’s name.
  5. How do labels aid users without screen readers? They clarify purpose, enlarge clickable areas, support speech input, and remain available when a user forgets placeholder hints.

References