HTML Snippet

Accessible Semantic Form Markup

Difficulty: Medium

A login or signup form is the highest-traffic interaction on most apps, and getting the semantic markup right pays dividends in screen-reader support, autofill quality, and form validation. This snippet covers a labelled email-and-password form, a form-with-error-summary using `aria-describedby`, and a multi-step fieldset pattern for grouped inputs.

Code Snippets
/

Accessible Semantic Form Markup

Accessible Semantic Form Markup

A login or signup form is the highest-traffic interaction on most apps, and getting the semantic markup right pays dividends in screen-reader support, autofill quality, and form validation. This snippet covers a labelled email-and-password form, a form-with-error-summary using `aria-describedby`, and a multi-step fieldset pattern for grouped inputs.

HTML
Medium
3 snippets
html-elements
html-forms
accessibility
code-template

599 views

6

Every input needs a <label for="id"> (not just placeholder text) so screen readers announce the field name and clicking the label focuses the input. autocomplete="email" and autocomplete="current-password" give the browser and password manager the right hints, which is what triggers autofill and one-tap login. The type="email" activates email-style mobile keyboards and basic format validation; minlength="8" adds a server-side-friendly client check. These tiny attributes make the difference between a clunky and a polished login.