In HTML, I want to show a <label>
placed with my textbox to show only for screen readers or voice browsers. what are the ways to achieve that with respect to WAG-ARIA guidelines and I would also like to know the vice versa scenario of hiding some text only from voice browsers ?
The best way I have found is to make a class you can toggle that will use CSS to hide text visually. The code I've used is:
.hidden
{position:absolute;
left:-10000px;
top:auto;
width:1px;
height:1px;
overflow:hidden;}
As for hiding text only from screen readers, what sort of situation would be requiring that?
To do this just use some CSS to position it offscreen. This will hide the label visually, unless they disable stylesheets. You don't really need ARIA here, unless you are trying to something more fancy than you are saying.
who on earth disable stylesheets?
I cannot give a percentage, but I disable them periodically due to a number of things. I had to do it this morning to fill out a form because their CSS and JS was wonky.
I would also like to know the vice versa scenario of hiding some text only from voice browsers ?
I really dont know what you mean by this. I'll take a shot in the dark, and say you are talking about people who use Dragon NaturallySpeaking. Hiding label
s actually detracts from user experience. For screen readers, JAWS, NVDA, VoiceOver, it does the following: Oh hey I am in a textbox, is there a label with a for attribute with my ID? Yes there is, then announce the text in the label
. Dragon works almost in the opposite way. It recogizes that the text is a label, and it matches up, the form element gets focus when the person says the word(s) in the label, such as First Name.
Looking at the other answer, if they are interpreting this question correctly as: "How do [or can] hide parts of a page from a screen reader?" The answer is yes you can by using the aria-hidden
attribute. I answered a question about aria-hidden
the other day, the links within that may provide insight.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With