button-name-present

Buttons have an accessible name

automaticWCAG 4.1.2 (A)confidence: highseverity: seriousrobust

Checks that buttons expose a non-empty accessible name.

Applies to. Applies to <button>, <input type="button">, <input type="submit">, <input type="reset"> and elements with role="button", where the element is included in the accessibility tree. role="presentation"/"none" takes an element out of scope unless a global ARIA attribute or focusability restores its role, per presentational roles conflict resolution.

Expectation. The element has a non-empty accessible name. A programmatic name is taken first (aria-labelledby, aria-label, an associated <label>, title). Failing that, an <input> button falls back to its value attribute, and type="submit"/type="reset" fall back to the user agent's own "Submit"/"Reset" default, which is why those two are never nameless. Failing both, a button whose role is name-from-content falls back to its subtree text, counting each descendant's own name (an <img alt>, aria-label or title) rather than only text nodes.

Examples

pass
<button>Save</button>

The button's text content is its accessible name.

fail
<button></button>

The button has no text content, `aria-label`, or `aria-labelledby`.

View source