Warning: Undefined array key "HTTP_REFERER" in /hosting/xtmci/inc/lib.inc.php on line 80
How to include MathJax for LaTeX in HTML files
xtmci

How to include MathJax for LaTeX in HTML files

Sat May 16 3:57 pm EDT 2026
xtmci@atomicmail.io

Key points

  • Load the MathJax component file in your HTML file.
  • Try some example LaTeX code and check the results.

How to do it

Add the following <script> tag inside the <head> section of your HTML file:

<script defer src='https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js'></script>

Alternatively, you can add this tag at the end of the <body> section.

Enter some LaTeX code in your HTML file, for example:

$$
  \frac{1}{\sigma \sqrt{2\pi}} e^{\textstyle\frac{-(x-\mu)^2}{2\sigma^2}}
$$

This LaTeX code should render as shown below:

$$ \frac{1}{\sigma \sqrt{2\pi}} e^{\textstyle\frac{-(x-\mu)^2}{2\sigma^2}} $$