With javascript, the typical way to encode mathematical formulas in webpages is with a library like KaTeX. KaTeX is a server-side rendering library for LaTeX expressions and is highly performant, but it relies heaily on a linked javascript file which goes against the philosphy of this website.
With my existing knowledge rendered useless, I turned my attention to the Mozilla developer docs (a great source for reading web documentation) and discovered MathML, short for Mathematical Markup Language.
MathML isn't new, but it only received full support in Chromium-based browsers (i.e. became reliable for most web users) in 2023. It uses an XML-based language in place of LaTeX in order to make rendering native in the browser. In practice, it is likely easiest to write formulas using LaTeX and use an online or terminal-based converter to translate it into MathML.
For instance, in standard LaTeX you can write the quadratic formula as the following:
\[
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\]
The equivalent in MathML is the following:
<p><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mo>=</mo><mfrac><mrow><mi>−</mi><mi>b</mi><mo>±</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo>−</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}</annotation></semantics></math></p>
This is clearly too unwieldly to work with directly; however, it does work nicely in HTML:
You can easily make the conversion from LaTeX snippet to MathML (as I did for this example) using Pandoc online. Simply:
These instructions are almost verbatum copied from USC's Using Pandoc to Convert LaTeX to HTML and MathML page.
Last updated March 20, 2026