26

We failed an accessibility audit on our signup once: unlabeled inputs, an error summary that never got announced, focus that jumped to the top of the page after validation. Retrofitting a11y is miserable, so now I bake it into the generation prompt.

The key was to stop treating accessibility as a checklist appended at the end and instead specify the exact behaviors: programmatic labels, a focus-managed error summary that receives focus on submit, live-region announcements, and a visible focus style that isn't just the browser default I'll later remove. I also make the model output how it would test each requirement.

This produces flows that pass an axe run on the first try. Prompt below. How far do you push automated a11y checks before you trust a generated form?

THE PROMPT
Build a signup + first-run flow as accessible HTML + minimal JS (no framework). Fields: {FIELDS}. This must pass an automated a11y audit (axe) AND keyboard-only use on the first try.

ACCESSIBILITY REQUIREMENTS (build these in, do not append as an afterthought):
- Every input has a programmatically associated <label> (not placeholder-as-label). Group related fields in <fieldset><legend>.
- Inline validation: on submit, if errors exist, render an error summary at the top, move keyboard focus to it, and link each item to its field. Associate each field's message via aria-describedby and set aria-invalid.
- Use a polite aria-live region for async status ('Checking availability...', 'Account created').
- Visible :focus-visible style with >= 3:1 contrast against the background; never remove outlines without a replacement.
- Logical DOM order == visual order; the flow is fully operable with keyboard only; no focus traps except an intentional modal that returns focus on close.
- Respect prefers-reduced-motion for any step transitions.
DELIVER: the code, then a short TEST PLAN table: requirement -> how to verify (axe rule name, or the exact keyboard steps), so I can confirm each one. Real microcopy, no filler.
moving focus to the error summary on submit is the single most-skipped behavior and the one auditors always catch. glad it's first-class here.promptsmith 2 months ago
add a comment

2 Answers

10

This is the right mental model: a11y is behavior, not a checklist you staple on. The test-plan table is what makes it real. I add one more requirement - error messages must be specific and recovery-oriented ("Password needs 8+ characters" not "Invalid password"), because a screen reader user hearing "invalid" with no guidance is stuck. Vague errors fail the spirit of the audit even when they pass the automated one.

THE PROMPT
Require every validation message to name the exact constraint and how to fix it (e.g. 'Enter a valid email like name@company.com'), never a generic 'invalid'/'required'.
7

One mobile caveat I hit: models love type="text" for everything, which gives the wrong on-screen keyboard and no autofill. Specify inputmode and autocomplete tokens (email -> inputmode=email autocomplete=email, one-time codes -> autocomplete=one-time-code). It's an accessibility and a conversion win because the phone does the work for the user.

THE PROMPT
For each field specify the correct type, inputmode, and autocomplete token so mobile shows the right keyboard and autofill works (email, tel, new-password, one-time-code, etc.).

Your Answer