Is using the <math> tag to write chemical equations semantically correct?
Asked Answered
C

1

6

I have been writing chemical equations in HTML files using the <math> element.

For example, to display MnSO4, I would type:

<math>
    <mi>M</mi>
    <mi>n</mi>
    <mi>S</mi>
    <msub>
        <mi>O</mi>
        <mn>4</mn>
    </msub>
</math>

Is this semantically correct? And if not, could you recommend an alternative?

Chloramine answered 6/5, 2023 at 14:50 Comment(1)
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.Deppy
W
9

MathML is "an XML-based language for describing mathematical notation". It was developed because mathematical notation requires more than a single line of typographic symbols, and is therefore difficult to represent in just text.

In contrast, chemical formulae are always "limited to a single typographic line of symbols, which may include subscripts and superscripts."

Because MathML is for math (not chemistry) and a chemical formula never needs more than a single line of text, it would be more semantic to use the <sup> (Superscript) and <sub> (Subscript) elements that are native to HTML.

<p>Plants require CO<sub>2</sub> for photosynthesis.</p>

You could also consider combining this with an <abbr> abbreviation element if you need to semantically note the name of a chemical.

<p>Plants require <abbr title="carbon dioxide">CO<sub>2</sub></abbr> for photosynthesis.</p>

You could also consider using an <i> Idiomatic Text to offset chemical equations from other text. This element is used to represent "a range of text that is set off from the normal text for some reason, such as idiomatic text, technical terms, taxonomical designations, among others."

<p>Hydrogen and oxygen can combine to form water: <i>2H<sub>2</sub> + O<sub>2</sub> → 2H<sub>2</sub>O</i></p>
Waddle answered 8/5, 2023 at 19:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.