Code has been added to clipboard!

HTML Subscript: Using sub Tags

Reading time 1 min
Published Jun 29, 2017
Updated Sep 11, 2019

HTML Subscript: Main Tips

  • To make plain text into a subscript HTML element, you should use <sub> tags. Both starting and ending tags must be used.
  • HTML subscript has a lower baseline and occupies less height than usual text.
  • The <sub> tag does not have specific attributes, but supports global ones.

HTML Code for Subscript

By surrounding inline text with <sub> tags, you turn it into subscript in HTML:

Example
<p>This text contains <sub>subscript</sub> text.</p>

HTML subscript <sub> tag uses this default CSS styling:

Example
sub {
    vertical-align: sub;
    font-size: smaller;
}

Tip: you can learn more about these properties in CSS vertical-align and fonts tutorials.

Using Subscript in HTML

You should only use HTML subscript for typographical reasons, for example:

  • footnote numbers
  • variable subscripts
  • chemical formulas
Example
<!-- Here you can see footnote numbers: -->
<p>I do not like green eggs<sub>1</sub> and ham<sub>2</sub>!</p>
<!-- Here you can see variable subscripts: -->
<p>2<sub>3</sub>,  4<sub>5</sub>, x<sub>y</sub></p>
<!-- Here you can see chemical formulas: -->
<p>H<sub>2</sub>O, NaHCO<sub>3</sub>, C<sub>12</sub>H<sub>22</sub>O<sub>11</sub></p>

Tip: in other cases, use CSS styling properties.

Browser Support

Chrome
All
Edge
All
Firefox
1+
IE
All
Opera
All
Safari
All

Mobile Browser Support

Chrome
All
Firefox
4+
Opera
All
Safari
All
Basics
Introduction
Syntax
Editors
Basic Examples
Head Section
<!DOCTYPE>
Tags and Elements
Semantic Elements
Tags Reference
Attributes
Comments
Block and Inline Elements
Forms
Form Elements
Input
Responsive Web Design
Inline Scripts
Uniform Resource Locator
Redirect
XHTML
Geolocation
Drag and Drop
Local Storage
Web Workers
Server-Sent Events
Character Encoding
Text Formatting
Quotation and Citation Elements
Headings
Paragraphs
Links
Tables
Lists
Symbols
Space
Tab
Styles
Computer Code
Layout
Classes
Colors
Images
iframes
Audio Player
Video Player
YouTube Videos
Multimedia
Canvas
SVG
<!-- -->
<a>
<abbr>
<acronym> DEPRECATED
<address>
<applet> DEPRECATED
<article>
<aside>
<audio>
<b>
<base>
<basefont> DEPRECATED
<bdi>
<bdo>
<big> DEPRECATED
<blink> DEPRECATED
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center> DEPRECATED
<cite>
<code>
<col>
<colgroup>
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<dir> DEPRECATED
<div>
<dl>
<dt>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<font> DEPRECATED
<footer>
<form>
<frame> DEPRECATED
<frameset> DEPRECATED
<h1> – <h6>
<head>
<header>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<keygen> DEPRECATED
<label>
<legend>
<li>
<link>
<main>
<map>
<mark>
<menu>
<menuitem> DEPRECATED
<meta>
<meter>
<nav>
<noframes> DEPRECATED
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike> DEPRECATED
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<tt> DEPRECATED
<u>
<ul>
<var>
<video>
<wbr>