I write a lot of mathematical articles (example) and wonder what the best way is to mark numbers/formulas within text.
I was using Latex mostly, but I would try to avoid it and use an inline HTML element instead, where suitable.
For now I am using <code>123</code> (styled as inline with CSS), which results in easy to read text blocks such as:
But since it is not code, it is semantically not correct.
Element Research
I tried to find the semantically most suitable HTML element. These are my results:
- The
<var>HTML element:
The element represents a variable in the context of either mathematics or computer programming.
But not for number(s), formula(s).
Also
<q>(inline quote),<abbr>or<dfn>do not seem applicable.<data>seems a bit broad and goes with a data attribute.<mark>would be a candidate.
"This tag highlights content because of its special relevance in some context."
As you can see, I am guessing around and need advice.
The <math> Tag
There is a separate <math> element (reference).
The element is used to include math expressions in the current line.
It is designed for the usage with MathML. HTML cannot be used inside, as the content gets rendered with expected MathML syntax.
Example:
<math>∫_a_^b^{f(x)<over>1+x} dx</math>
<math>Z<sub>1</sub> = 100 €</math>
Result:
∫_a_^b^{f(x)1+x} dx Z1 = 100 €
The first example works fine, the second one fails (and is not even rendered).
... complete MathML expression must be contained in tags. (...) The presence of enclosing tags should be a reasonable heuristic test for MathML content. (...) However, the problem of supporting HTML in MathML presents many difficulties. (...) Therefore, at present, the MathML specification does not permit any HTML elements within a MathML expression.
