How to write formulas using HTML

Let’s create formulas in HTML as shown below.

HTML uses tags to specify the presentation, layout, and formatting of a document. Tags start with opening angle bracket (<) and close with closing angle bracket (>).

Tags required to create a formula, as shown above, are:

<sup> tag: defines superscript text.

<sub> tag: defines subscript text.

(x + y)<sup>2</sup>&nbsp;&nbsp;=&nbsp;&nbsp;x<sup>2</sup> + 2xy + y<sup>2</sup>

As you can see above <sup> tag is used to represent the power symbol in HTML and <sub> represents the subscript, as shown below.

So how do you represent subscript text in HTML such as the formula for acetate.

C<sub>2</sub>H<sub>3</sub>O<sub>2</sub><sup>-</sup>&nbsp;&nbsp;&nbsp;&nbsp;acetate

Where &nbsp; represent space in HTML.

If you understand the above examples, you can easily represent the rest of the formulas shown. In this way, we create formulas in HTML using <sub> and <sup> tags.

--

--