Subscripts in HTML

In HTML5
2 min read

Sub HTML TAG

The <sub> HTML tag is used to create subscript text. Subscript text is smaller than the surrounding text and often denotes an exponent, a chemical formula, or a mathematical notation. The <sub> tag can be used inline with regular text or within block-level elements such as paragraphs or headings.

Code Example

Here’s an example of how to use the <sub> tag in HTML:

<p>The formula for water is H<sub>2</sub>O, where 2 denotes the number of oxygen atoms.</p>

In this example, the number “2” would appear as a subscript below the letter “O.”

Tag Attributes

  • align: Specifies the alignment of the subscript text. Values can be either superscript or subscript.
  • href: Specifies the link URL to be followed when the user clicks on the subscript text.
  • src: Specifies the location of an image to be displayed as the subscript text.
  • alt: Provides alternative text for the subscript text, used when the browser cannot render the image or other media.
  • title: Provides a tooltip that displays additional information about the subscript text when the user hovers over it.
  • class: Specifies one or more class names for the subscript text that applies CSS styles to the element.
  • id: Specifies a unique ID for the subscript text to create links to specific web page sections.

These attributes can be used to customize the appearance and behavior of the <sub> tag in various ways. For example, you can use the align attribute to position the subscript text relative to the surrounding text or use the href attribute to create a hyperlink from the subscript text to another web page.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Carlos Baez

Subscribe now to keep reading and get access to the full archive.

Continue Reading