HTML Tools for Mathematics — MathML, MathJax, KaTeX (2026 Stack)
Writing mathematics for the web in 2026 is finally easy — MathML has native support across Chrome, Safari, and Firefox. But the toolchain depends on what you’re coming from: LaTeX source, markdown, or already-rendered PDFs. This snippet is the current stack I use for math.gauravtiwari.org and the Mathematical Sciences textbook work.
I’ve been writing maths for the web since 2008 when the only reliable option was rendering each equation as a PNG and hoping the baseline alignment didn’t break. MathJax 1.0 arrived in 2009 and dominated for a decade, but it weighs 400 KB and blocks rendering until every equation finishes typesetting. KaTeX (Khan Academy, 2014) was faster but missed features. Native MathML in browsers finally shipped properly in 2023 (Chrome added it, Safari and Firefox had it earlier). In 2026, the right tool genuinely depends on your use case.
The 2026 math-on-the-web stack
- Native MathML — built into Chrome 109+, Safari 14+, Firefox (always). Zero JavaScript, perfect accessibility, instant render
- KaTeX — best for server-side rendering. 60 KB, synchronous, outputs pre-styled HTML. The choice when you author in LaTeX
- MathJax v4 — still the feature leader for advanced LaTeX, custom macros, and accessibility. 400 KB, async, slower
- temml — LaTeX to MathML converter. Gives you the LaTeX authoring experience with MathML’s rendering speed
- Pandoc — converts LaTeX source to HTML+MathML or HTML+MathJax. Essential for publishing existing LaTeX books to web
- Obsidian + Marp — my current authoring chain for math-heavy notes → web publishing
Quickstart by use case
Pick the path that matches what you’re starting from. All four of these are production-ready in 2026.
<!-- PATH 1: Native MathML (authored by hand or via temml) -->
<p>The Pythagorean theorem:</p>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<msup><mi>a</mi><mn>2</mn></msup>
<mo>+</mo>
<msup><mi>b</mi><mn>2</mn></msup>
<mo>=</mo>
<msup><mi>c</mi><mn>2</mn></msup>
</math>
<!-- PATH 2: KaTeX — author in LaTeX, render server-side or client-side -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css">
<script src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/auto-render.min.js" defer></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
renderMathInElement(document.body, {
delimiters: [
{ left: "$$", right: "$$", display: true },
{ left: "$", right: "$", display: false }
]
});
});
</script>
<p>Author inline like $a^2 + b^2 = c^2$ or block:</p>
<p>$$ \int_0^1 x^2 \, dx = \frac{1}{3} $$</p>
<!-- PATH 3: LaTeX to MathML via temml (build time, static output) -->
<!-- CLI: temml input.tex > output.html -->
<!-- PATH 4: Pandoc — convert a whole LaTeX book to HTML -->
<!-- pandoc book.tex --mathml -s -o book.html -->Picking the right one
If you’re starting from scratch with a handful of equations per page, native MathML is the right answer — zero dependencies, fastest render, works in email clients and RSS readers. If you’re porting a LaTeX-authored book or textbook to the web, use temml at build time to convert LaTeX to MathML once, serve static HTML, skip the client-side JS entirely. If you need heavy custom macros or LaTeX packages that don’t have MathML equivalents (tikz, pstricks), MathJax v4 is still your only realistic option. KaTeX sits in the middle — LaTeX authoring, fast render, limited to a subset of LaTeX but covers 95% of mathematical content.
Download and source
- Native MathML reference: MDN MathML docs
- KaTeX: katex.org (MIT, 60 KB gzipped)
- MathJax v4: mathjax.org (Apache 2.0, 400 KB)
- temml: github.com/ronkok/Temml (LaTeX to MathML converter)
- Pandoc: pandoc.org (universal document converter, essential for big LaTeX imports)
- My actual authoring chain for math.gauravtiwari.org: Obsidian + Pandoc + Hugo + static MathML output
FAQs
Isn’t MathML officially dead?
Quite the opposite. MathML Core (a pragmatic subset of the full MathML spec) shipped in all three major browsers by 2023 after years of stagnation. Chrome’s MathML Core implementation in 109+ is the reason this stack changed — there’s finally a universal, JS-free renderer.
Should I still use MathJax in 2026?
Only if you need its advanced features: custom TeX macros, accessibility narration, large equation libraries that depend on LaTeX packages. For standard mathematical content, native MathML or KaTeX both render faster and without the 400 KB cost.
What about ASCIIMath, LaTeX-it, or the equation picture generators?
Equation images are still the worst option — no accessibility, no semantics, blurry on high-DPI. ASCIIMath is a notation layer on top of MathJax and is rarely worth adopting in 2026. LaTeX-it (macOS app that generates equation PDFs) is fine for one-off slides but don’t use it for web content.
How do I render equations in WordPress?
For KaTeX: the KaTeX plugin registers shortcodes and a script. For MathJax: the MathJax-LaTeX plugin. For native MathML: just write it inline in a Custom HTML block — WordPress passes it through unchanged to the output.
What about handwritten math input?
Mathpix (commercial, $4.99/month) is the best OCR for scanned handwritten math — converts a photo of your whiteboard to LaTeX. For typed input that feels like writing, use a note-taking app with a LaTeX mode: Obsidian, Logseq, or the iPad app Notability (2026 version has native LaTeX).
How do screen readers handle MathML?
Native MathML + ARIA descriptions is the most accessible path. NVDA and JAWS read MathML well with the built-in math accessibility mode. VoiceOver on macOS and iOS reads MathML natively since 2022. KaTeX emits ARIA attributes that work almost as well. Rendered equation PNGs are inaccessible — never use them.
Thanks for the info. Very good post!