Nearby lessons

22 of 24

πŸ”½ <sub> Tag

πŸ“Œ What is the <sub> Tag?

The <sub> HTML tag is used to define subscript text. Subscript text appears half a character below the normal line and is typically used in chemical formulas or mathematical expressions.

Example usage includes H2O or CO2.

πŸ“Œ Syntax

Use the <sub> tag to wrap the text you want to appear as subscript.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

πŸ” Use Cases

  • Chemical formulas (e.g., CO2)
  • Mathematical expressions (e.g., an)
  • Footnotes or citations in academic writing

βš™οΈ Attributes

AttributeDescription
Global AttributesThe <code>&lt;sub&gt;</code> tag supports all global attributes in HTML.
Event AttributesSupports event attributes like <code>onclick</code>, <code>onmouseover</code>, etc.

βœ… Best Practices

  • Use <sub> only for subscript semantics, not visual styling.
  • Avoid overusing subscript in body text to maintain readability.
  • Pair <sub> with <sup> when both are needed (e.g., chemical equations).
  • Use semantic tags for clarity and accessibility, especially in academic or scientific contexts.
  • Use CSS for layout and styling rather than relying on <sub> for spacing or alignment.

🧠 Test Your Knowledge

2 Questions

Progress: 0 / 2
Keep Going!HTML Superscript