Building HTML forms by hand is tedious.
You forget a name attribute. You miss a for on a label. Accessibility breaks. Validation fails silently.
Whether you're building a simple contact form or a complex multi-step Typeform-style experience, the foundation is always the same: solid, semantic HTML.
Let's look at what makes a form accessible and how to build one without losing your mind.
The Accessibility Problem
Forms are the most common point of failure for web accessibility. If a screen reader can't understand your form, the user can't complete it.
The most common mistakes:
-
Missing Labels: Using placeholders instead of
<label>elements. -
Broken Associations: Having a label, but forgetting the
forattribute to link it to the input'sid. -
Missing Names: Forgetting the
nameattribute, which means the data never gets submitted. -
Silent Errors: Not using
aria-liveregions oraria-invalidto announce validation errors to screen readers.
The Manual Way (The Foundation)
A perfect, accessible input looks like this:
<div class="form-group">
<label for="email">Email Address</label>
<input
type="email"
id="email"
name="email"
required
aria-required="true"
autocomplete="email"
/>
</div>
You need:
- The
forattribute on the label matching theidon the input. - The
nameattribute for form submission. - The correct
type(e.g.,email,tel,password). - The
requiredattribute for native validation. -
autocompletefor better user experience.
Writing this for 20 fields takes time. Writing it for a complex form with checkboxes, radio groups, and select dropdowns takes even longer.
The Step-by-Step Form Problem
If you want a Typeform-style experience, you add JavaScript and CSS to the mix.
You need to:
- Hide all steps except the current one.
- Animate the transition between steps.
- Validate the current step before allowing the user to proceed.
- Manage focus (move focus to the first input of the new step).
- Announce the step change to screen readers using
aria-live.
This is complex. If the underlying HTML isn't perfect, the JavaScript will break.
The Visual Way
If you want to build the accessible HTML foundation without writing every tag by hand, I built a free HTML Form Code Builder.
What it does:
- Visually designs HTML5 forms
- Adds validation attributes automatically
- Generates accessible, semantic markup
Why it's useful:
- No installation
- No upload (100% client-side)
- Ensures you don't miss
for,id, ornameattributes - Fast
Try It
100% client-side. Nothing uploaded.
What's your biggest frustration with building forms? Let me know in the comments.
Top comments (0)