Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tell a screen reader to ignore placeholder text within an input tag?

Some of the placeholder text I have in my app is a bit ridiculous for a screen reader (a sample MAC address, for example).

Is there a way I can tell a screen reader to ignore only the placeholder text?

like image 650
Ajv2324 Avatar asked Mar 30 '16 15:03

Ajv2324


People also ask

How do I stop screen reader reading placeholder?

The best way is to add a hidden label and associate input element with attribute to the respective label.

Can screen readers read placeholder text?

Assistive technologies, such as screen readers, do not treat placeholder text as labels. Moreover, at the time of writing this tutorial, placeholder text is not broadly supported across assistive technologies and not displayed in older web browsers.

How do I hide text and make it accessible by screen reader?

The conventional way is to use CSS ( display:none; and visibility:hidden; ) or the HTML 5 `hidden` attribute. These properties hide elements not only on the screen, but also for screen reader users. Thus, these elements will not be visible nor vocalized by Assistive technologies (AT).


1 Answers

You can use a meaningful placeholder. If you really want to define what a mac address should look like but don't want it to be read (for whatever reason), you can use the aria-hidden attribute on some other element.

<label>MAC Address:
   <input type="text" placeholder="Enter your mac address here" />
   <span aria-hidden="true">(e.g. FF-AA-BB-CC-DD-EE)</span>
</label>

We can guess that a blind user who will have to type its MAC address should already know what it looks like. Best way would be to provide a help link to a glossary.

like image 119
Adam Avatar answered Oct 05 '22 23:10

Adam