← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

Accessible Forms

accessibility HTML5 Intermediate

Also Known As

form accessibility aria-describedby

TL;DR

Every input needs a visible label, errors linked via aria-describedby, required fields indicated, and validation announced via aria-live.

Explanation

Label via for/id or wrapping — never placeholder-only. Errors: aria-describedby links error to input; aria-invalid=true on invalid inputs. Required: required attribute or aria-required. Autocomplete attribute helps password managers. Announce errors with role=alert or aria-live=polite.

Watch Out

An input with only a placeholder and no associated label is invisible to screen readers — the field exists but has no announced purpose, causing silent confusion for blind users.

Common Misconception

Placeholder is a sufficient label — it disappears on focus, has poor contrast, and is not consistently announced as a label.

Why It Matters

Inaccessible forms exclude users relying on screen readers, keyboard navigation, and voice input — typically 15–20% of users to some degree. Missing label associations mean screen readers announce 'edit text' with no context. Missing error associations mean validation failures are invisible to assistive technology. In regulated industries, inaccessible forms are a legal liability. Fixing them also improves usability for everyone — clearer labels and inline errors reduce form abandonment rates measurably.

Common Mistakes

  • Placeholder as label
  • Errors not linked to inputs
  • Required indicator without explanation
  • Validating on every keystroke

Avoid When

  • Do not use placeholder text as a substitute for a visible label — placeholders disappear on input and fail contrast requirements.
  • Avoid grouping unrelated fields inside a single fieldset — it creates confusing context for screen reader users.

When To Use

  • Apply accessible form patterns to every form — not just those explicitly flagged for accessibility review.
  • Use aria-describedby to link error messages to their input so screen readers announce the error when focus moves to the field.
  • Use aria-live regions for dynamic validation feedback that appears without a page reload.

Code Examples

💡 Note
The bad example uses a placeholder and an unlinked error span; the fix adds a label element, aria-describedby pointing to the error, and aria-live so the validation is announced automatically.
✗ Vulnerable
<input type="email" placeholder="Email">
<span style="color:red">Invalid</span>
✓ Fixed
<label for="email">Email *</label>
<input id="email" type="email" aria-required="true" aria-invalid="true" aria-describedby="err">
<span id="err" role="alert">Enter a valid email</span>

Added 16 Mar 2026
Edited 31 Mar 2026
Views 48
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 1 ping W 0 pings T 2 pings F 1 ping S 0 pings S 0 pings M 0 pings T 1 ping W 0 pings T 3 pings F 1 ping S 0 pings S 0 pings M 0 pings T 1 ping W 2 pings T
Amazonbot 1 Perplexity 1
Amazonbot 15 Perplexity 14 Unknown AI 5 ChatGPT 3 Ahrefs 3 SEMrush 2 Majestic 1 Google 1 Meta AI 1
crawler 43 crawler_json 1 pre-tracking 1
DEV INTEL Tools & Severity
🟠 High ⚙ Fix effort: Medium
⚡ Quick Fix
Every input needs a visible label (for/id not placeholder), errors linked via aria-describedby, required marked with aria-required, and validation announced with role=alert
📦 Applies To
any HTML5 web
🔗 Prerequisites
🔍 Detection Hints
Placeholder as only label; error message not linked via aria-describedby; required fields not marked; custom error styling without role=alert
Auto-detectable: ✓ Yes axe lighthouse wave
⚠ Related Problems
🤖 AI Agent
Confidence: High False Positives: Medium ✗ Manual fix Fix: Medium Context: File Tests: Update

✓ schema.org compliant