Coding Hubs School of AI – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 8448811540
Back to HTML Notes
Topic #215

Subscript (sub)

The <sub> tag lowers text slightly below the normal line and shrinks it — used for chemical formulas and mathematical indices.

Syntax

<sub>lowered text</sub>

Basic Example

<p>Water's chemical formula is H<sub>2</sub>O.</p>

Browser output: the "2" renders smaller and shifted below the baseline — the standard way chemical formulas are printed.

How It Works

The browser shrinks the font size and shifts the text downward via vertical-align and font-size in its default stylesheet — the mirror image of how <sup> works.

Important Attributes

AttributePurpose
— none —Only universal global attributes apply

Real-World Example

<p>In algebra, a sequence's terms are often written x<sub>1</sub>, x<sub>2</sub>, x<sub>3</sub>, and so on.</p>

Exactly how indexed variable names appear in a math or computer science course's notes.

Common Mistakes

  • Overusing <sub> for general small-text styling that has nothing to do with chemistry or math notation
  • Nesting too many sub/sup levels, producing text that's genuinely hard to read

Best Practices

  • Keep <sub> content short, exactly like <sup>
  • Use it only for genuine subscript meaning — chemical formulas, indexed variables, mathematical notation

Accessibility Considerations

Same caveat as <sup> — screen reader announcement of subscript varies, so don't rely on it alone to convey meaning in critical content.

SEO Considerations

No direct ranking effect.

Browser & Modern HTML Notes

Stable and simple, unchanged across HTML versions.

Mini Practice

  1. Write the chemical formula for carbon dioxide (CO<sub>2</sub>) using <sub>.
  2. Write a short sequence of indexed variables (x<sub>1</sub>, x<sub>2</sub>) using <sub>.

Related HTML Notes

Want to go beyond the notes?

Join Coding Hubs School of AI's HTML course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →