×

Subscripts and Superscripts [12/17]

The next two tags are used to format individual characters rather than words. They are used in measurement units or simple mathematical expressions.

For example, 20m2, H2O, X3 + X2=1

The <sup> tag renders text in superscript.

The <sub> tag displays text in subscript.

Please note that these tags are purely presentational and have no semantic meaning of their own.

They can be nested inside each other to make up more complex formulas.

However, if you wish to insert a very sophisticated mathematical expression in your HTML document, you'd better use a special markup language called MathML.


Do it
HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Subscripts and Superscripts</title> </head> <body> <h1>Formulas</h1> <ul> <li>H2SO4</li> <li>sin2x+cos2x=1</li> <li>C2H5OH</li> <li>e-x2</li> </ul> </body> </html>
CSS
HTML Academy
  1. Format the first formula as follows: H2SO4,
  2. and the second formula as: sin2x + cos2x = 1.
  3. For the third formula, find proper formatting yourself.
  1. The fourth formula is even more sophisticated: make your own try.
Theory Check Next