Using the HTML Tag for Subscript Text: Creating Mathematical and Scientific Notations
Learn how to use the HTML tag to create subscript text for mathematical formulas, chemical formulas, and other notations. This tutorial explains its functionality, typical rendering, and how to customize its appearance using CSS for improved readability and visual appeal.
Using the HTML Tag for Subscript Text
Understanding Subscript
The HTML <sub>
(subscript) tag is used to mark up text that should be displayed as a subscript—slightly smaller text that appears below the baseline. This is particularly useful for representing mathematical formulas, chemical formulas, or other notations where a character or number is intended to be lowered relative to the surrounding text. While browsers generally render subscript text in a smaller font size and with a vertical offset, you can further refine its appearance using CSS (Cascading Style Sheets).
Using the Tag
To create subscript text, simply place the text you want to subscript within the opening and closing <sub>
tags. For example:
Example: Basic Subscript
<p>The chemical formula for water is H<sub>2</sub>O.</p>
Browser Support for
The `<sub>` element enjoys wide support across major modern browsers.
Browser | Support |
---|---|
Chrome | Yes |
Edge | Yes |
Firefox | Yes |
Opera | Yes |
Safari | Yes |
Default Styling and CSS Customization
Most browsers will render the `<sub>` element with a smaller font size and a vertical alignment below the baseline. You can customize this using CSS:
Example: Custom CSS for
sub {
vertical-align: sub;
font-size: smaller;
color: blue;
}