HTML: the aria-pressed attribute

The aria-pressed attribute communicates whether a toggle button is currently on or off.

What you will learn

Basic example

<button type="button" aria-pressed="false">
  Add to favorites
</button>

The button starts in the off state. When the user toggles it, JavaScript should update aria-pressed to true and update the visible style or label so the state is clear.

Allowed states

<button type="button" aria-pressed="true">
  Favorites added
</button>

Use a real button

Apply aria-pressed to a button that toggles a state. Do not replace the button with a clickable div; a native button already supplies keyboard behavior and the correct role.

Common mistakes