HTML Basics

HTML Introduction HTML Basic HTML Comments HTML Tags/Elements HTML Attributes HTML Formatting HTML Block and Inline HTML Charsets HTML Classes HTML Colors HTML Div HTML Headings HTML Id HTML Iframes HTML Images HTML File Paths HTML Tables HTML Layout HTML Lists HTML Links <a> HTML Paragraphs HTML Quotations HTML JavaScript HTML Emojis HTML URL Encode HTML Entities HTML Computercode HTML Symbols HTML Styles

HTML Forms

HTML Forms HTML Form Elements HTML Form Attributes HTML Input Attributes HTML Input Regex HTML Input Form Attributes HTML Input Types

HTML SEO

HTML Head HTML Page Title HTML Responsive HTML Semantics HTML Favicon

HTML Graphics

HTML Canvas HTML SVG

HTML Media

HTML Media HTML Audio HTML Video

HTML Reference

a abbr acronym address applet area article aside audio b base basefont bdi bdo big blockquote body br button canvas caption center cite code col colgroup data datalist dd del details dfn dialog dir div dl DOCTYPE dt em embed fieldset figcaption figure font footer form frame frameset h1_-_h6 head header hgroup hr html i iframe img input ins kbd label legend li link main map mark menu meta meter nav noframes noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script search section select small source span strike strong style sub summary sup svg table tbody td template textarea tfoot th thead time title tr track tt u ul var video wbr

HTML <sub> Tag

Introduction

The <sub> tag in HTML is used to define subscript text. Subscript text appears slightly below the normal line of text and is commonly used for footnotes, mathematical expressions, chemical formulas, and more. In this tutorial, we will explore how to use the <sub> tag effectively in your HTML documents.

Usage

To use the <sub> tag, simply place the text you want to be subscripted within the opening and closing tags. For example:

<p>H<sub>2</sub>O is the chemical formula for water.</p>

This will produce the following output: H2O is the chemical formula for water.

Attributes

The <sub> tag does not have any specific attributes of its own, as it is a standalone tag. However, it inherits some of the global attributes of HTML, such as class, id, style, and title.

Main Tag Attributes

Attribute Description
class Defines a class name for the element, allowing you to apply CSS styles.
id Defines a unique id for the element, which can be used for JavaScript interactions.
style Defines inline CSS styles for the element.
title Defines a title for the element, usually displayed as a tooltip when the mouse hovers over it.

For example, you can apply a specific class to the <sub> tag to style it differently:

<sub class="important">Important Text</sub>

Conclusion

The <sub> tag is a powerful tool in HTML for displaying subscript text. By using it appropriately and understanding its attributes, you can enhance the readability and visual appeal of your content. Experiment with different styling options and see how the <sub> tag can elevate your HTML documents!