Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
783 views
in Technique[技术] by (71.8m points)

accessibility - how does a screenreader treat the utf-8 checkmark character in a td of an HTML table?

I have HTML tables in which checkmarks, within are used to indicate whether, say jam (column head, th) is available as (row th = flavor) grape, or strawberry.

The checkmark can be a gif, in which case the alt tag of the img tag tells a screenreader that this is a checkmark.

But suppose instead of an img, the utf-8 checkmark character is used. Does Jaws, for example, say "checkmark"?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In theory you should be able to use any UTF-8 character.

However in practice this can be "clunky" in some screen readers (reading "special character" "character name") and in some they are ignored entirely as they are assumed to be decorative. These tend to be less used screen readers, JAWS and NVDA both behave quite well.

With that being said, you are probably best using the following for how best to deal with special characters.

  1. Is the special character purely decorative i.e. a smiley emoji - if yes hide it with <span aria-hidden="true">Your UTF-8 Character</span>.
  2. If it isn't purely decorative, does the sentence / paragraph make sense without it? If yes, you are yet again probably best hiding it from screen readers. Or if you are willing to go the extra mile use step 3.
  3. If the character is important / you want to offer a top notch experience for screen readers you should hide the special character as with steps 1 and 2 but then add a visually hidden span that contains the character description. An example of this is below.

One thing to note in the below example is I do not replace "checkmark" with text that says the same. Instead I replace it with the words that make most sense (which in your example was "available"). This provides the best possible experience to screen reader users.

.visually-hidden { 
    border: 0;
    padding: 0;
    margin: 0;
    position: absolute !important;
    height: 1px; 
    width: 1px;
    overflow: hidden;
    clip: rect(1px 1px 1px 1px); /* IE6, IE7 - a 0 height clip, off to the bottom right of the visible 1px box */
    clip: rect(1px, 1px, 1px, 1px); /*maybe deprecated but we need to support legacy browsers */
    clip-path: inset(50%); /*modern browsers, clip-path works inwards from each corner*/
    white-space: nowrap; /* added line to stop words getting smushed together (as they go onto seperate lines and some screen readers do not understand line feeds as a space */
}
<p>
    <span aria-hidden="true">&#x2713;</span>
    <span class="visually-hidden">Available</span>
</p>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...