DEV Community

Discussion on: Website Accessibility: How can I make sure screenreaders interpret the text in the way I intend?

Collapse
 
alvaromontoro profile image
Alvaro Montoro • Edited

In HTML, you can use the <abbr> tag to specify abbreviations and acronyms, using the title attribute to specify what the abbreviation/acronym stands for:

<p>I want a cheeseburger <abbr title="with">w/</abbr> tomato and lettuce.</p>
Enter fullscreen mode Exit fullscreen mode

Unfortunately, screen readers won't read the title and will try to read the text as is ("w slash" instead of "with"). You can fix that by adding an aria-label with what you want the screen readers to read. This would be equivalent to the "readas" attribute that you mentioned:

<p>I want a cheeseburger <abbr aria-label="with" title="with">w/</abbr> tomato and lettuce.</p>
Enter fullscreen mode Exit fullscreen mode

With that, some screen readers read it as desired (Chromevox) but others still read "w slash" and broke the sentence in parts (VoiceOver). Adding a role="text" to the paragraph helped with this:

<p role="text">I want a cheeseburger <abbr aria-label="with" title="with">w/</abbr> tomato and lettuce.</p>
Enter fullscreen mode Exit fullscreen mode

After that, VoiceOver and Chromevox read it the same way: "I want a cheeseburger with tomato and lettuce." But I recall some a11y experts mentioning role="text" not having full support (would need to look into it), so I don't know how good of an idea it is to use it.

It is funny because sometimes screen readers are smart enough to interpret this type of acronyms correctly, and some other times they need a little help.

Collapse
 
baenencalin profile image
Calin Baenen

Sometimes they may "need help" since they're trying to be "accurate", instead of being "correct". At least, that's why I think it happens.

But, I had a question about <abbr>, is title required for the example that included aria-label?
I know title also adds a tooltip to the element, and I don't want that.

Collapse
 
alvaromontoro profile image
Alvaro Montoro

title is not required. With the tooltip, you'd be providing the same information to screen reader users and sighted users, which is important. But we could say that "w/" is a commonly known/used abbreviation and there's no real need for the title/tooltip. So it should be ok without it.