Give buttons accessible names
November 2, 2020

If you try to run an audit check from Google or any other services, you might get an accessibility error saying that, “Buttons do not have an accessible name”.

When a button doesn’t have an accessible name screen readers and other assistive technologies announce it as button.

When someone who is a disabled and using hearing devices or any other means to get access to your website, the button will no serve any purpose. Because it will provide no information to users about what the button does.

How to add accessible names to buttons

For buttons with visible labels, add text content to the button element.

Make the label a clear call to action.

For example:

<button>Book room</button>

For buttons without visible labels, like icon buttons, use the aria-label attribute to clearly describe the action to anyone using an assistive technology.

For example:

<button class="btn" aria-label="Left Arrow">
   <span class="class-name" aria-hidden="true">left_arrow</span>


<button aria-label="Close" onclick="myDiv.close()">X</button>

The aria-label attribute

The aria-label attribute is used to define a string that labels the current element.

We can use it in cases where a text label is not visible on the screen.

If there is visible text labeling the element, use aria-labelledby instead.

This attribute can be used with any typical HTML element; it is not limited to elements that have an ARIA role assigned.



Leave a Reply

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to set opacity or transparency using CSS? #3 Pagination in CSS with multiple examples #4 How to make HTML form interactive and using CSS? #5 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

Mar 5 How to create flickering text using CSS? Mar 4 How to use data-* Attributes in HTML? Mar 4 The substr() method in JavaScript and how it’s different from substring() Mar 4 A complete guide to add responsive YouTube videos using HTML and CSS Mar 3 How to embed YouTube or other video links in WordPress? Mar 3 How to change the Login Logo in WordPress?

You might also like these

The SELECT DISTINCT Statement in SQLSQL/MySQLHow to add multiple Columns in CSS like Bootstrap?CSSHow to add AppRoutingModule in Angular application using command line?Angularbin2hex() and chr() String Functions in PHPPHPHow to add a ribbon on top of a container using CSS?CSSHow to create a horizontal scrolling menu with and without flex using CSS (or SCSS)?CSS