Skip to content

Latest commit

 

History

History
53 lines (35 loc) · 1.63 KB

README.md

File metadata and controls

53 lines (35 loc) · 1.63 KB

35. Accessible forms

Make form errors and groups understandable.

Learn

  • labels
  • fieldset
  • instructions
  • required state
  • error association
  • autocomplete

Build

Review your registration form with keyboard navigation and screen reader inspection.

Check your work

  • Open the result in a browser and inspect the HTML and computed CSS.
  • Test at narrow and wide widths and use the keyboard for interactive elements.
  • Write down one thing you changed after testing.

Deep lesson

How it works

Every form control needs an accessible name, usually from a visible label. Instructions and error text can be associated with the relevant control. Fieldset and legend describe a group as a whole. Required status and constraints should be clear before submission, and autocomplete can reduce typing. During an error, preserve the entered values and state how to fix the problem.

Common mistake

Color alone is not a complete error message. A group of radio buttons without a question can be hard to understand out of context.

Guided challenge

Build a contact preference group and one required field. Inspect its accessible name and description, then submit an empty value and write a useful error message.

Completion check

  • Rebuild the core idea without copying the example line by line.
  • Explain the key HTML or CSS choice in your own words.
  • Test the result at a narrow width and with keyboard navigation where relevant.

Run the example

Open example.html in a browser. Edit style.css, save, and refresh.

Try: Use a screen reader or accessibility tree to check each control name and description.