Welcome to Bucaro TecHelp!

Bucaro TecHelp
HTTPS Encryption not required because no account numbers or
personal information is ever requested or accepted by this site

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Creating a Subscript or Superscript with HTML

A subscript is a number, letter, or symbol written directly next to and slightly below a word or phrase that can be used to reference the word or phrase to a footnote. A subscript is also used in chemistry to indicate the number of atoms of an element in a molecule. To create a subscript, use the <sub></sub> tag, as shown below.

The chemical formula for water is H2O, and the formula for Hydrogen Peroxide is H2O2.

<p>The chemical formula for water is H<sub>2</sub>O, and the formula
for Hydrogen Peroxide is H<sub>2</sub>O<sub>2</sub>.</p>

If you want to use a subscript reference a footnote, note that the <sub> tag responds to the onclick event. This means, you can use Java Script with the document's location object, to set it up so the user can click on the subscript and be taken to the footnote, as shown below.

Click on the number1 to be taken to the footnote

<p>Click on the number<sub style="color:blue;" onclick="javascript:location='#footnote1';">1</sub> to be taken to the footnote</p>

Example code for a footnote is shown below.

<p><a name="footnote1"><sup>1</sup></a> This is the footnote text</p>

A superscript is a number, letter, or symbol written directly next to and slightly above a a number, letter, or symbol. A superscript is frequently used in mathematics to indicate and exponent. To create a superscript, use the <sup></sup> tag, as shown below.

Mass and energy are related as defined by Einstein's formula E=mC2, where energy (E) is equal to the mass (m) multiplied by the speed of light (C) squared.

<p>Mass and energy are related as defined by Einstein's formula E=mC<sup>2</sup>,
where energy (E) is equal to the mass (m) multiplied by the speed of light (C) squared.</p>

Many webmaster's today prefer to use CSS as much as possible to replace html. In that case, you can replace the <sub> or <sup> with the <span> tag and then use the vertical-align style property to set the verticle position of the subscript or superscript, as shown below.

The chemical formula for water is H2O

<p>The chemical formula for water is H<span style="vertical-align:-0.5em">2</span>O</p>

Einstein's formula is E=mC2

<p>Einstein's formula is E=mC<span style="vertical-align:0.4em">2</span></p>

The above examples use in-line style to offset the subscript or superscript vertically by 0.5em. An em unit is equal to the height of the capital letter "M" in the currently defined font size.

1 This is the footnote text

More HTML Code:
• Most Usefull ASCII Character Code Entities
• HTML Bulleted or Unordered List
• HTML5 Slider Control
• Make an HTML Element Editable
• HTML5 Spinbox Control
• HTML abbr and acronym Tag
• Image Map Basics
• Creating a Subscript or Superscript with HTML
• HTML List Basics
• The Heading Tags

Follow Stephen Bucaro Follow @Stephen Bucaro

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2024 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268