Which HTML tag is used to create a subscript text?

Understanding the HTML Subscript Tag

HTML, or HyperText Markup Language, provides several tags to style and format text. One such tag is the <sub> tag, which is used to create subscript text.

What is Subscript Text?

Subscript text appears slightly below the baseline of the normal text and is often smaller. It's commonly used in scientific formulas - for example, in the formula for water, H2O, the "2" is a subscript.

Usage of HTML &lt;sub&gt; Tag

Using the <sub> tag is simple: Just wrap the text you want to make subscript in opening (<sub>) and closing (</sub>) tags.

For example:

<p>This is an example of <sub>subscript text</sub>.</p>

In the above code, 'subscript text' will be displayed as a smaller font sized text slightly below the rest of the text in the web page.

HTML &lt;sub&gt; Tag Best Practices

  • The <sub> tag should typically be used for text that is genuinely subscript, such as chemical formulas or mathematical expressions. Do not use the <sub> tag simply to make text smaller or lower - use CSS instead for more flexible text sizing and positioning.

  • Although it might seem similar, subscript text <sub> is distinct from superscript text <sup>. Superscript is text that is raised and smaller than surrounding text, often used for footnotes or exponentiation (i.e., powers, like 2³).

Ensuring that you use the correct HTML tag for the job not only ensures your web pages will look the way you expect them to, but it also helps with accessibility. Many screen readers and other assistive technologies rely on correct semantics in HTML to give their users the best experience possible.

So understanding the use of HTML subtitle <sub> tag plays an important role in formulating an effective HTML document structure.

Do you find this helpful?