Friday, December 14, 2007

How to create superscript and subscript

You can insert the following css code inside the head tag i.e. between <head> and </head>

<style type="text/css">
.subscript {vertical-align: sub; }
.superscript {vertical-align: super;}
</style>

and use the class defined above in your html code as follows:

<span class="subscript">2</span>
<span class="superscript">2</span>

for example,

CO2 and E=mc2

becomes

CO2 and E=mc2

1 comment:

Susu Kacang said...

Another way:

<sub>subscript</sub>
<sup>superscript</sup>