Form
Buttons
Published on
Description
Buttons trigger in-page actions such as form submission, toggling state, or opening dialogs. Use <button> for actions — never <a>, <div>, or <span>.
Example
Accessibility
- Links navigate (
<a href>), buttons act (<button>), and submit buttons send form data (<button type="submit">). Using the wrong element breaks keyboard expectations. - Buttons activate on both Enter and Space. Links activate on Enter only.
- Never use
<div>or<span>withrole="button"— this creates keyboard accessibility issues. - Ensure a minimum target size of 44x44 CSS pixels (WCAG 2.5.5 Level AAA, 24x24 minimum for 2.5.8 Level AA).
- Don't disable submit buttons. Users cannot understand why interaction is blocked. Use error messages instead.
References
- Links, Buttons, Submits, and Divs, Oh Hell (opens in new tab) — Adrian Roselli
- Styling Links and Buttons (opens in new tab) — Adrian Roselli
- Multi-Function Button (opens in new tab) — Adrian Roselli
- Don't Disable Form Controls (opens in new tab) — Adrian Roselli
- Target Size and 2.5.5 (opens in new tab) — Adrian Roselli
Related
Variables
None for form buttons