Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lighthouse error: "Buttons do not have an accessible name"

How do I fix this Lighthouse error:

Buttons do not have an accessible name

<button class="search-button" type="submit" value="Search"></button>

I'm a beginner.

like image 255
Mehmetk Avatar asked May 10 '19 17:05

Mehmetk


People also ask

How do you fix buttons do not have an accessible name?

Adding Text Content to the Button Element The simplest way to add accessible names to buttons is to add text content to the button element. This displays the text on the button's visible label (and if the button doesn't have a visible label, keep reading).

When a button doesn't have an accessible name?

When a button doesn't have an accessible name, screen readers and other assistive technologies announce it as button, which provides no information to users about what the button does.

When a button doesn't have an accessible name screen readers announce it as button making it unusable for users who?

When a button doesn't have an accessible name, screen readers announce it as “button”, making it unusable for users who rely on screen readers.

Do buttons need title?

Short answer. Yes, your button must have so form of text label associated with it.


1 Answers

I would recommend this link for reference.

https://developers.google.com/web/tools/lighthouse/audits/button-name

It suggests that the button should have inner text content or an aria-label or aria-labelledBy.

<button class="search-button" type="submit">Search</button>

<button class="search-button" type="submit" aria-label="search"></button>

I have shown a button with inner text and also a button with an aria-label.

like image 127
JakeofSpades Avatar answered Sep 27 '22 19:09

JakeofSpades