How do you do equations in HTML?

Equations cannot be directly written in HTML. However, you can use MathML (Mathematical Markup Language) to write equations in HTML. MathML is an XML-based language for describing mathematical notation and capturing both its structure and content. You can use MathML tags to write equations in HTML.

In HTML, you can display equations using several approaches depending on your specific needs. Here are two common methods:

1. MathML (Mathematical Markup Language): MathML is an XML-based language specifically designed for formatting and displaying mathematical equations. To use MathML in HTML, you can use the `<math>` tag along with various MathML elements, such as `<mrow>`, `<msup>`, `<mfrac>`, etc., to represent different parts of the equation. However, note that not all web browsers fully support MathML, so it may not be universally compatible.

Example:

```html
<!DOCTYPE html>
<html>
<head>
<title>MathML Example</title>
</head>
<body>
<math>
<mrow>
<mi>x</mi>
<mo>=</mo>
<mfrac>
<mrow>
<mo>-b</mo>
<mo>±</mo>
<msqrt>
<msup>
<mo>b</mo>
<mn>2</mn>
</msup>
<mo>-</mo>
<mn>4</mn>
<mo>*</mo>
<mi>a</mi>
<mo>*</mo>
<mi>c</mi>
</msqrt>
</mrow>
<mrow>
<mo>2</mo>
<mi>a</mi>
</mrow>
</mfrac>
</mrow>
</math>
</body>
</html>
```

2. LaTeX: LaTeX is a widely used typesetting language for scientific and mathematical documents. While LaTeX is not native to HTML, you can render LaTeX equations in HTML using JavaScript libraries such as MathJax or KaTeX. These libraries allow you to write LaTeX code within HTML elements and render them as equations in the browser.

Example using MathJax:

```html
<!DOCTYPE html>
<html>
<head>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS_CHTML"></script>
</head>
<body>
<div>
\(x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\)
</div>
</body>
</html>
```

Ensure you have an active internet connection when using MathJax or KaTeX, as they load the necessary scripts from external servers.

With either approach, you can customize the equation's styling using CSS or the options provided by the chosen library.

To create equations in HTML, you can use MathJax, which is a JavaScript library that allows you to display mathematical equations on web pages.

Here are the steps to use MathJax in your HTML:

1. Include MathJax library: Add the following script tag in the head section of your HTML document to include MathJax from the official MathJax CDN (Content Delivery Network):

```html
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
```

2. Write the equation: To write an equation, use the \( \(\LaTeX\) syntax inside a pair of dollar signs (\$).

For example, here's how you can write the quadratic equation:

```html
<p>The quadratic equation is \(ax^2 + bx + c = 0\).</p>
```

3. Surround the equation with a container element: To ensure MathJax processes the equation correctly, wrap it inside a span element with the class "MathJax" and an "id" attribute.

```html
<p>The quadratic equation is <span class="MathJax" id="equation">\(ax^2 + bx + c = 0\)</span>.</p>
```

4. Enable MathJax rendering: At the end of your HTML document, add the following script tag to enable MathJax to process the equations on the page:

```html
<script type="text/javascript">
MathJax.Hub.Queue(["Typeset", MathJax.Hub, "equation"]);
</script>
```

That's it! Save your HTML file, open it in a web browser, and you should see the equation rendered by MathJax.

Note: Make sure you have an internet connection since MathJax is being loaded from a CDN.