← Back to Catalog

Real button with type; Space vs Enter

real-button-with-type-space-vs-enter

Use a real `<button>` with `type` set (`submit` / `button` / `reset`; default is submit). Do not use `<a>` or `<div>` as the only control. Space triggers a button; Enter triggers a link — do not style links as buttons without that difference.

Description

USWDS requires a real `<button>` with `type` set to `submit`, `button`, or `reset` (default is submit). Do not use `<a>` or `<div>` as the only control. Space triggers a button; Enter triggers a link—do not style links as buttons without that difference. Omitting `type` on a non-submit button so it submits, or relying on an anchor/div as the sole control, fails.

When to use

Implementing clickable actions that submit, reset, or run in-page commands.

Not when

Anchor navigation that should remain a real link, not a faux button.

Agent hint

Use <button> with explicit type; do not make <a> or <div> the only button control.

Pass

The control is `<button>` with an explicit `type`. Links are not styled as the only button control.

Fail

`<a>` or `<div>` is the only control, or `type` is omitted on a non-submit button so it submits.

Citations

Open UX · cited UX rules agents audit against

Privacy · Sources ·