Accessibility Wiki

Buttons in forms should declare a type

Rule button-type · Links & buttons · impact minor · Static + live

↩ Back to the rules index · WCAG cross-reference

Why it matters

A <button> with no type defaults to type="submit". Inside a form — or associated to one from outside via the form="id" attribute — an unrelated button (e.g. "Show password") then submits the form unexpectedly: an unexpected behavior change on activation rather than a name/role/value defect.

How to fix

Add type="button" to buttons that should not submit; use type="submit" deliberately.

Example

✕ Fails
<form><button>Toggle</button></form>
✓ Passes
<form><button type="button">Toggle</button></form>

Example

✕ Fails
<form id="checkout"></form><button form="checkout">Apply coupon</button>
✓ Passes
<form id="checkout"></form><button form="checkout" type="button">Apply coupon</button>

The form attribute associates the button with the form even from outside it.

WCAG success criteria

3.2.2 On Input — Level A

Changing a control’s value (picking an option, typing) must not automatically trigger a change of context unless the user was warned beforehand.

Understanding 3.2.2

Standards

This rule contributes to the following standards:

WCAG A EN 301 549 Best practice

Standard Criteria
EN 301 549 9.3.2.2

References

Generated from the EqualWeb accessibility engine’s rule metadata. Back to top ↑