How to include MathJax for LaTeX in HTML files
Sun May 3 6:41 pm EDT 2026
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}} $$