Accessible login flows: WCAG compliance for authentication UX
A sighted keyboard user tabs into your login form and the focus ring vanishes. A screen reader user hits an error that only appears as a red border. Someone with dyslexia is asked to retype a one-time code from memory across two screens. None of these people filed a bug, and all of them left. A login screen is the narrowest gate in your product, and when it fails accessibility it fails silently and completely.
WCAG 2.2 moved the goalposts toward auth
The 2.2 revision added success criterion 3.3.8, Accessible Authentication (Minimum), and it targets exactly the patterns auth teams love. The rule says a login step must not rely on a cognitive function test — remembering a password from memory, transcribing a code, solving a puzzle — unless there is an alternative or a mechanism that helps. Crucially, it carves out exceptions for things users do not have to recall or transcribe by hand.
The practical reading: let password managers fill the password field, let the browser autofill a one-time code, and never block paste. A CAPTCHA that makes users transcribe distorted text is a clear violation, because it is a cognitive function test with no assist. Image CAPTCHAs that ask users to pick out traffic lights are a subtler case: they fall under the criterion’s object-recognition exception, so they technically pass at AA — but they still burden the users this rule protects and are disallowed at the stricter AAA level (3.3.9 Accessible Authentication (Enhanced)), so avoid them. Email and SMS codes are fine if the user can copy-paste or the platform auto-fills them, because then the user is not performing the memory test themselves.
The single most common 3.3.8 failure is onpaste="return false" on password and OTP fields. Teams add it thinking it improves security; it does the opposite. It breaks password managers, forces error-prone retyping, and fails WCAG. Delete it.
Labels the machine can actually read
A placeholder is not a label. Placeholders disappear on focus, fail contrast requirements, and are inconsistently exposed to assistive technology. Every input needs a programmatically associated label, and every error needs to be tied to its field so a screen reader announces it in context.
<form aria-labelledby="signin-heading">
<label for="email">Work email</label>
<input id="email" name="email" type="email"
autocomplete="username"
aria-describedby="email-error" required>
<p id="email-error" role="alert"></p>
<label for="password">Password</label>
<input id="password" name="password" type="password"
autocomplete="current-password"
aria-describedby="password-error" required>
<p id="password-error" role="alert"></p>
</form>Two details carry a lot of weight here. The autocomplete tokens username and current-password are what let browsers and password managers fill the form, which is both a UX win and part of satisfying 3.3.8. And aria-describedby wiring the input to its error paragraph means that when you populate #password-error, the assistive technology reads the message as part of the field, not as orphaned text somewhere on the page.
Errors that get announced, not just colored
Color alone never conveys state — that is WCAG 1.4.1. An invalid field needs a text message, a programmatic association, and ideally a live announcement. Put errors in a container with role="alert" (or an aria-live="assertive" region) so they are spoken the moment they appear, and move focus to the first invalid field on submit failure.
- Describe the fix, not just the fault: "Enter the 6-digit code from your authenticator app," not "Invalid input."
- Keep the error visible — do not auto-dismiss it after a timer.
- Never reveal whether the email or the password was wrong; "Email or password is incorrect" is both the secure answer and a perfectly accessible one.
Focus order and keyboard operability
Everything in a login flow must work from the keyboard alone, in a logical order, with a visible focus indicator (WCAG 2.4.7, strengthened by 2.4.11 Focus Not Obscured in 2.2). The failure modes cluster around custom widgets:
- Modal dialogs for MFA. If you pop a dialog for a code, trap focus inside it, return focus to the trigger on close, and let Escape dismiss it.
- Custom OTP inputs. The six-separate-boxes pattern is a focus-management minefield. If you build it, support paste-to-fill across all boxes and left/right arrow navigation; a single input with
inputmode="numeric"andautocomplete="one-time-code"is far safer. - "Show password" toggles. Make them real buttons with an accessible name that reflects state, not click handlers on a bare icon.
Passkeys are an accessibility upgrade
It is easy to treat WebAuthn and passkeys purely as a phishing-resistance story, but they are one of the strongest accessibility moves available. A passkey has no memory test, no code to transcribe, and no field to mistype — the platform authenticator handles it with a biometric or PIN the user already uses. That satisfies the spirit of 3.3.8 directly. Offer passkeys as a first-class option and you remove the hardest cognitive load from the flow for everyone.
If you support hardware security keys and passkeys, make sure the "try another way" path is keyboard reachable and clearly labeled. Users whose primary method fails should never be stranded on a screen with no visible escape to a backup factor.
Testing it for real
Automated scanners like axe-core catch missing labels and contrast failures, and you should run them in CI against your login, signup, MFA, and reset screens. But they catch maybe half of what matters. The other half needs a human doing three things: tabbing through the entire flow with the mouse unplugged, running it under an actual screen reader (NVDA or VoiceOver), and trying it at 200% and 400% zoom to confirm nothing clips or overlaps (WCAG 1.4.10 Reflow). Budget that pass for every release that touches an auth screen, because these screens change less often and break more quietly than the rest of your app.
Accessibility at the login gate is not a feature you bolt on — it is a property of how the flow is built, which means it is far cheaper to own than to retrofit. When you run your own auth, the markup, the error semantics, and the passkey path are all yours to get right, instead of being whatever a hosted widget happened to render. Bastionary ships its login, MFA, and recovery flows to WCAG 2.2 AA and hands you the templates so you can keep them there.
Run it yourself
Bastionary is free, open-source software. Follow the quick start to have it running on your own server, or browse the releases on Git.