Forms & accessibility

Controlled vs uncontrolled, validation UX, focus management, ARIA basics, keyboard navigation. Accessible forms separate product engineers from demo builders.

About 25 min read3-question knowledge check

The mental model

A form is the place where your app takes responsibility for someone else's data and intent. Every other part of the UI shows things; a form changes things. That is why forms are where product engineers are separated from demo builders — a demo shows a happy path, a real form must handle the person who tabs instead of clicks, the person on a screen reader, the double-submitter, the paste-a-huge-string person, and the flaky network. Accessibility is not a bolt-on for that; it is the same discipline as correctness, viewed through a different input device.

The mental model that organises everything: **the browser already knows how to do forms well; your job is mostly to not break what it gives you, and to fill the small gaps.** A native form has, for free: labels that move focus to their field, Enter to submit, Tab order following the DOM, required-field and type validation, autofill, and full screen-reader semantics. The moment you replace a native element with a div and JavaScript, you inherit the obligation to reimplement *all* of that — and almost nobody does it completely. So the first rule of accessible forms is **use the platform**: a real label, a real input, a real button type="submit", a real fieldset. The div-with-onClick "button" that a mouse user cannot tell apart from a native one is invisible to a keyboard and a screen reader.

The analogy: think of the browser's form machinery as a building already fitted with ramps, handrails, and clear signage. You can build your own staircase that looks nicer, but now you owe the ramp, the handrail, the braille sign, and the fire exit — and you will forget one. Accessibility bugs are almost always "someone rebuilt a native control and left out the part the platform gave away."

The full lesson continues with 15 more sections
  • Deep dive
  • Internal architecture
  • Real-world use cases
  • Best practices
  • Common mistakes
  • Performance
  • Security
  • Production troubleshooting
  • Advantages & disadvantages
  • Alternatives
  • Interview expectations
  • Interview questions
  • Facts to remember
  • Cheat sheet
  • Quick revision