EN
HTML - MathJax example
10
points
In this article, we would like to show how to use MathJax library directly with HTML.
The main advantage of this approach is, we are able to use math syntax directly in HTML couse code - it is not necessary to use JavaScript.
Practicale example:
// ONLINE-RUNNER:browser;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" async></script>
</head>
<body>
<p>
When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are
\[x = {-b \pm \sqrt{b^2-4ac} \over 2a}.\]
</p>
</body>
</html>
Note: the example comes from this webpage.
More examples
Copy one of the below codes to the example to see how it works.
| Code | Preview |
\(y-y_0=m(x-x_0)\) | |
\(\cos^2θ+\sin^2θ=1\) | |
\(∑_{i=0}^n i={n(n+1) \over 2}\) | |
\(f'(x)=\lim_{h→0}{f(x+h)-f(x) \over h}\) | ![]() |
\(d(x, y) = \max(|x_1-y_1|, |x_2-y_2|)\) |
