Nearby lessons
22 of 24π½ <sub> Tag
π What is the <sub> Tag?
The
Example usage includes H2O or CO2.
<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
π Use Cases
- Chemical formulas (e.g., CO2)
- Mathematical expressions (e.g., an)
- Footnotes or citations in academic writing
βοΈ Attributes
| Attribute | Description |
|---|---|
Global Attributes | The <code><sub></code> tag supports all global attributes in HTML. |
Event Attributes | Supports 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 QuestionsProgress: 0 / 2
Keep Going!HTML Superscript