What component has
|Moves focus to the next focusable element.|
|Moves focus to the previous focusable element.|
|Activates the button.|
Roles & attributes
The list below describes roles and attributes that component already has.
|Identifies the element as a button. Accessible name for the button is defined by the text content of the element or by adding |
|Includes the element in the |
|Identifies the button as a toggle button. Indicates the toggle button isn’t pressed.|
|Identifies the button as a toggle button. Indicates the toggle button is pressed.|
Considerations for developers
<button>tag doesn't need anything special to work. Use
- Ensure visual labels and programmatic labels match.
- Just like links, you can add
class="visuallyhidden"with descriptive text to give more context to the button's purpose.
- Usually, SVG icons should be hidden from screen readers on a button that has a text label.
- You can use
<input type="image">to make a graphical button. It takes a
altattribute just like traditional images.
- Button states are important, not just button styling! If you are only toggling classes to visually manage state of your components, you are likely not appropriately conveying that state to users of assistive technologies.
- If there is no text in the button, it is necessary to add aria-label with a button description.
Find live examples in the A11y style guide.
Roles and attributes
The list below will help you to keep in mind the necessary roles and attributes to make our components fully accessible in the particular cases in your interfaces.
|Defines a string value that labels an interactive element. It is a required for buttons without text content.|
- W3 button examples has detailed information about the button accessible behavior.
- A11y style guide gives recommendations for the accessible components.
- Find live examples of accessible inputs with different types in DigitalA11y project.
See more accessibility recommendations in the common Accessibility guide.