htmlaccessibilityscreen-readersjaws-screen-reader

Do screen readers understand HTML escape characters (like " for double quotes)?


I'm updating a aria-label value method that's currently escaping the value to be safely used in a HTML element attribute.

So it would convert <span> abc" to &lt;span&gt; abc&#34;, for example.

The issue is that the JAWS reads it as it is, it doesn't translate the encoding.

Is this a characteristic of all (or most) of the screen readers? Or that's just a bug?

My initial solution for this would be to convert the symbols that requires (or is usually) to be escaped (<,>, ", ', and &) to its name (e.g. < would be converted to "less than"). Is this a valid solution?


Solution

  • So your aria-label is going to include HTML entities? I'm not sure I follow that scenario. An aria-label is just announced as is and special characters don't have to be escaped. So if you want an aria-label to say "<span>", you can just have aria-label="<span>". The aria-label isn't rendered so nothing has to be escaped.

    Now, most screen readers have a "verbosity" setting so some punctuation and special characters are not announced by default, but the user has total control over that. So in the aria-label="<span>" example, a screen reader might only say "span". But if the user changes their verbosity to read all special characters, then it might say "less than, span, greater than".