Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Screen readers: How to make a word with tags surrounding its letters be spoken as a single word, rather than a series of letters?

I have a heading like this:

<h1>This is a t<span>e</span>st.</h1>

The tags around the letter "e" cause Mac OS X Voiceover to read the individual letters of the word separately, rather than the full word. So, it speaks:

"This is a t e st."

Instead of:

"This is a test."

Given that I need to enclose a letter of a word in a tag*, how can I make sure that the screen reader speaks the word as normal?

  • N.B: any tag will do. I've tried <b>, <i> and <em> and they all generate the same effect.
like image 539
peterhartree Avatar asked Jun 08 '13 20:06

peterhartree


People also ask

Which tag is read by screen readers with a different tone to convey its importance?

Screen readers use HTML tags to understand the content and regions of the page, and what elements are available for the user to select. For this reason, the most effective way to make your web pages accessible is to structure your HTML code with semantically rich tags.

What symbols can screen readers read?

Screen readers read most punctuation by default, such as parentheses, dashes, asterisks, and so on, but not all screen readers choose to read the same pieces of punctuation. Some do not read asterisks by default, for example.

Is text-to-speech the same as a screen reader?

Screen readers are used by those who are visually impaired and need help navigating their devices while text-to-speech software can be used by anyone who wants to listen to digital text rather than read it themselves.


1 Answers

One way to work around this quirk is by offering a screen-reader-only version of the text alongside the tidbit that’s throwing off screen readers, such as:

CSS snippet:

.offscreen
{
    position: absolute;
    clip: rect(1px 1px 1px 1px); /* for Internet Explorer */
    clip: rect(1px, 1px, 1px, 1px);
    padding: 0;
    border: 0;
    height: 1px;
    width: 1px;
    overflow: hidden;
}

Markup example:

<h1>This is a 
    <span aria-hidden="true">t<strong>e</strong>st</span>
    <span class="offscreen">test</span>.
</h1>

There, the aria-hidden attribute hides the troublesome tidbit from screen readers (<span aria-hidden="true">t<strong>e</strong>st</span>) and the offscreen class visually hides the screen-reader version of the text (<span class="offscreen">test</span>).

The end result is that screen-reader users will hear “This is a test” and sighted users will see “This is a test” within the page.

like image 80
Ashley Bischoff Avatar answered Sep 17 '22 13:09

Ashley Bischoff