Skip to content

Form Input Missing Label Accessibility Fix

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about Form Input Missing Label Accessibility Fix. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

Form inputs without associated labels are inaccessible to screen readers. Users who rely on assistive technology cannot identify what information each input expects. This is one of the most common WCAG failures on the web.

Quick Fix

Step 1: Use explicit label with for/id

<!-- Wrong — no label associated with input -->
<input type="text" placeholder="Enter your name">

<!-- Right — label with for attribute -->
<label for="name">Full Name</label>
<input type="text" id="name" placeholder="Enter your name">

Step 2: Wrap input with label

<!-- Alternative — input inside label (no for/id needed) -->
<label>
    Full Name
    <input type="text" name="name">
</label>

Step 3: Use aria-label when label is not visible

<!-- Wrong — icon-only button, no accessible name -->
<button>
    <span class="icon-search"></span>
</button>

<!-- Right — add aria-label -->
<button aria-label="Search">
    <span class="icon-search"></span>
</button>

Step 4: Use aria-labelledby with existing visible text

<!-- Wrong — input with separate text but no connection -->
<p>Search for products</p>
<input type="text">

<!-- Right — connect the text to the input -->
<p id="search-label">Search for products</p>
<input type="text" aria-labelledby="search-label">

Step 5: Handle select, textarea, and fieldset

<!-- Wrong — select without label -->
<select>
    <option value="">Choose country</option>
    <option value="us">United States</option>
</select>

<!-- Right — label for select -->
<label for="country">Country</label>
<select id="country">
    <option value="">Choose country</option>
    <option value="us">United States</option>
</select>

<!-- Use fieldset for grouped inputs -->
<fieldset>
    <legend>Contact Preferences</legend>

    <label>
        <input type="checkbox" name="email"> Email
    </label>
    <label>
        <input type="checkbox" name="sms"> SMS
    </label>
</fieldset>

Step 6: Provide error messages with aria-describedby

<!-- Wrong — error text with no association -->
<label for="email">Email</label>
<input type="email" id="email">
<span class="error">Please enter a valid email</span>

<!-- Right — connect error to input -->
<label for="email">Email</label>
<input
    type="email"
    id="email"
    aria-describedby="email-error"
    aria-invalid="true"
>
<span id="email-error" class="error">Please enter a valid email</span>

Prevention

  • Every form input must have a label (visible or via aria-label)
  • Use <label for="id"> for visible labels
  • Use aria-label for icon-only inputs
  • Use aria-describedby for help text and error messages
  • Test forms with a screen reader to verify label announcements

Common Mistakes with form label

  1. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  2. Misunderstanding that String is [Char] with poor performance for large text operations
  3. Using foldl instead of foldl' causing stack overflow on large lists

These mistakes appear frequently in real-world A11Y code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Can placeholder replace a label?

No. Placeholder text disappears when the user types, fails contrast requirements, and is not a valid accessible name. WCAG explicitly requires labels. Placeholder can supplement a label but not replace it.

Do I need labels for hidden inputs?

No. Hidden inputs (type="hidden") are not visible or interactive and do not need labels. All visible form controls (text, select, checkbox, radio, textarea, button) need accessible labels.

How do I label a search input?

Use <label for="search">Search</label> for the best Accessibility. Alternatively, use aria-label="Search" on the input if you want a visual icon instead of a text label. The label must be present even if only via aria-label.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro