2

I sometimes have different chemical formulae in text, while there is no problem with formulae like H2SO4 (because it is read in the same way, both by people without visual impairments and by people using screen readers), the problem starts when by convention chemical formulae uses some symbols that are not correctly read by screen readers (and no, I can't avoid using such symbols, I can't use an image with an alt-text etc.). Examples:

  • H2C=CH2 — equals sign that means 'double bond', but is read by screen reader as an equals sign,
  • H2N–CH3 — en dash that means 'single bond', but in not read by a screen reader at all.

I tried to use an abbr with a proper description, but this is faulty, as most screen readers don't read abbr by default. title also does not solve this problem.

How the default meaning of '=' and '–' can be supressed to screen reader users and true meaning be presented?

2 Answers2

1

You can use "hidden" text that is not visually displayed but is read by screen readers and then "hide" the equals sign from the screen reader.

H2C=CH2 would look like:

H<sub>2</sub>C
  <span aria-hidden="true">=</span>
  <span class="sr-only">double bond</span>
CH<sub>2</sub>

(Carriage returns in code above for readability purposes)

The "=" is contained in a <span> that is aria-hidden so the screen reader will not see it.

The "double bond" will be read by the screen reader but will not be visible to the sighted users. The "sr-only" class is not anything special. It's just a common name for a class to make visually hidden text. See What is sr-only in Bootstrap 3?

I'm not a chemistry major so I don't know if it's correct to hear the above formula read as

"H 2 C double bond C H 2"

but you can always adjust the text in the "sr-only". Perhaps it should be "double bonded to"?

Note that some screen readers might adjust the inflection of the speech voice when it encounters subscripts or superscripts but the change might be subtle. Otherwise, most screen readers just read the subscript as if it were a regular number. So H2O would be read the same as H2O.

slugolicious
  • 15,824
  • 2
  • 29
  • 43
1

Short answer

You can use the off-screen technique as presented in the other answer, but while it might make things better for screen reader users, it poses issues for Braille display users.

It's probably better to leave the = as is in the text.

Longer answer

I'm a screen reader user myself, and we are used to situations like this where the screen reader says something when it means in fact something slightly different in the context we are currently in. We aren't stupid, we can still understand.

In your case here, if the user knows enough chemistry, he/she can easily understand that "equals" means "double bond". And if this is an introductory course, you will anyway need to explain that notation to everyone.

Adding an alternative "double bond" text instead of leaving the "=" as is is also extremely detrimental against braille users. I don't know enough about chemistry, but for math, for example, it would make a formula totally unusable. What do you think about:

open paren x plus one close paren squared equals x squared plus two x plus one

versus:

(x+1)² = x² + 2x + 1

You, as a sighted user, you immediately recognize and understand the second form, right?

For a braille reader, it's the same. IN the second case, he/she will understand immediately, because he/she knows the math symbols and what they mean. A good screen reader can even display the formula in the specific braille nemeth math notation, which is different from the braille used in normal text. Even an user who isn't using braille can easily go through the equation by reading character by character. This is very common to read things like that character by character.

IN the first case, it's impossible to display the formula in braille math, and the user has to twist his/her mind to first understand the english text before mentally switching back to math mode and understand what it means in math. That's excellent for cognitive load, isn't it?

Some software think they are doing well by converting all math formulas in plain text like in my example, but in fact they are making our live worse. For moderately complex formulas, the generated text quickly become very difficult to understand, much more than the original equation.

IN this math example, you'd better using MathML, which is a specific XML language made for math, or just plain unicode symbols are sufficient in many situations. IN both cases, screen readers become better at handling them as the time goes. If you want to be maximally accessible, additionally to using MathML, you should also give a plain ASCII equivalent or the source code used to generate the equation in a language like LaTeX. There are people who prefer reading plain code, and there are of course screen readers which don't support MathML (the support is quite recent and still ongoing). Therefore, by doing so, you are maximizing the chances that the screen reader user will understand either of the forms and will be able to work with it.

Now, what I have said is for math. I don't know at all what is the state of the art in chemistry, but I imagine that there exists something comparable to MathML. I don't know either if there is a specific braille for chemistry. If nothing comparable exists yet, it's maybe time to create something, and, in the meantime, stick to LaTeX or plain ASCII, just like when doing programming.

More generally, it would also apply for any other domain having specific notations. For example, in music, MusicXML is comparable to MathML, lilipon is comparable to LaTeX, and ABC notation could be the plain ASCII form.

Andy
  • 4,783
  • 2
  • 26
  • 51
QuentinC
  • 12,311
  • 4
  • 24
  • 37
  • Yes, there are methods for writing chemical formulae and reactions using solutions similar to MathML. However, it does not mean I can or should use it — putting a formulae using it inline with normal text would be less accessible for most users. And leaving some symbols without explanation could be unclear for people that can't see it (e.g. 'minus' symbol that is used for a negative charge in superscript, the same symbol as a minus alongside stoichiometric numbers, and as a single bond). – Piotr Skolimowski Aug 27 '22 at 00:56
  • I don't agree with you, but do what you want, there is no standard here anyway. You shouldn't decide for your users what is best for them. Ask them! I just gave you my own experience as a blind user who has been student in computer science at university, and what I think the best would be to make sciences accessible. For accessibility in general, simpler means often better, and plain text has the great advantage to be universally accessible when nothing more comfortable exists/works. – QuentinC Aug 27 '22 at 02:55
  • I'll give you a simple example: R2C−CXR2. Leaving this that way, it'll be spelled as R two C minus minus C X R two. Two minuses? Nope, just a minus symbol that acts here as a single bond. – Piotr Skolimowski Aug 27 '22 at 19:57
  • Screen readers can be configured to indicate `` and `` by changing the voice and/or saying something like "indice" or "exponent" and/or playing sound cues. It can also be shown in braille if desired. No, sorry, I'm pretty convinced that a goo enough skilled reader can perfectly handle it even if it says "minus" twice. Use a more specific unicode character if there is one and it's enough, really. – QuentinC Aug 27 '22 at 21:32