HTML5 Reference

HTML <sub>

Definition

The <sub> tag is used for defining subscript text.

Use the CSS vertical-align property for more control.

Example


<p>Some normal text <sub>This text appears lower on the line than normal text.</sub> More normal text.</p>

Some normal text This text appears lower on the line than normal text. More normal text.

Attributes

The following attributes can be used with the <sub> tag.


<sub> Specific Attributes
Attribute Value Description Example
There are no required or optional attributes specific to the <sub> tag.
<sub> Global Attributes
Attribute Description Example
Common
classSpecifies a classname for the element allowing you to apply the style of the predefined class to the content.

<sub class="name">Subscript Text</sub>
idSpecifies a unique id for the element allowing you to apply the style of the predefined id to the content.

<sub id="name">Subscript Text</sub>
styleSpecifies an inline style for the element allowing you to apply the style to the contentt.

<sub style="color:red;">Subscript Text</sub>
titleSpecifies an inline style for the element allowing you to apply the style to the content.

<sub title="Content info">Subscript Text</sub>
Keyboard
accesskeySpecifies a keyboard shortcut to associate with the element.

<sub accesskey="a">Subscript Text</sub>
tabindexSpecifies a tab order for the element.

<sub tabindex="1">Subscript Text</sub>
Language
dirSpecifies the directional flow of the content.

<!-- The text will flow from left to right -->
<sub dir="ltr">Subscript Text</sub>
<!-- The text will flow from right to left -->
<sub dir="rtl">Subscript Text</sub>
langSpecifies a language code for the content of the element.

<sub lang="en">Subscript Text</sub>
spellcheckSpecifies an inline style for the element allowing you to apply the style to the contentt.

<!-- Valid values true and false. -->
<!-- Default inherited / browser specific. -->
<sub spellcheck="true">Subscript Text</sub> 
translateSpecifies an inline style for the element allowing you to apply the style to the content.

<!-- Valid values yes and no. -->
<!-- Default yes. -->
<sub translate="no">Subscript Text</sub> 
Miscellaneous
contenteditableSpecifies whether the content of the element is editable.

<!-- Valid values true and false. -->
<!-- Default inherited. -->
<sub contenteditable="true">Subscript Text</sub> 
draggableSpecifies whether the element is draggable.

<!-- Valid values true and false. -->
<!-- Default browser specific. -->
<sub draggable="true">Subscript Text</sub>
hiddenSpecifies whether the element is not yet, or no longer, relevant.

<!-- Valid values an empty string or hidden -->
<sub hidden>Subscript Text</sub> 
<sub hidden="hidden">Subscript Text</sub> 
<sub> Event Attributes
Attribute Description Example
Document Element
oncopyThe script to be run when the user copies the content of an element.

 <!-- Executes go() function -->
<sub oncopy="go()">Subscript Text</sub> 
oncutThe script to be run when the user cuts the content of an element.

 <!-- Executes go() function -->
<sub oncut="go()">Subscript Text</sub>
onpasteThe script to be run when the user pastes some content into an element.

 <!-- Executes go() function -->
<sub onpaste="go()">Subscript Text</sub>
Drag and Drop
ondragThe script to be run when an element is dragged.

 <!-- Executes go() function -->
<sub ondrag="go()">Subscript Text</sub>
ondragendThe script to be run when an element has stopped being dragged.

 <!-- Executes go() function -->
<sub ondragend="go()">Subscript Text</sub>
ondragenterThe script to be run when an element has been dragged to a valid drop target.

 <!-- Executes go() function -->
<sub ondragenter="go()">Subscript Text</sub>
ondragleaveThe script to be run when an element leaves a valid drop target.

 <!-- Executes go() function -->
<sub ondragleave="go()">Subscript Text</sub>
ondragoverThe script to be run when an element is being dragged over a valid drop target.

 <!-- Executes go() function -->
<sub ondragover="go()">Subscript Text</sub>
ondragstartThe script to be run at the start of a drag operation.

 <!-- Executes go() function -->
<sub ondragstart="go()">Subscript Text</sub>
ondropThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<sub ondrop="go()">Subscript Text</sub>
Form
onblurThe script to be run when the element loses focus.

 <!-- Executes go() function -->
<sub onblur="go()">Subscript Text</sub>
onchangeThe script to be run when object changed and attempt to leave field.

 <!-- Executes go() function -->
<sub onchange="go()">Subscript Text</sub>
oncontextmenuThe script to be run when a context menu is triggered.

 <!-- Executes go() function -->
<sub oncontextmenu="go()">Subscript Text</sub>
onfocusThe script to be run when the element gets focus.

 <!-- Executes go() function -->
<sub onfocus="go()">Subscript Text</sub>
oninputThe script to be run when an element gets user input.

 <!-- Executes go() function -->
<sub oninput="go()">Subscript Text</sub>
oninvalidThe script to be run when an element is invalid.

 <!-- Executes go() function -->
<sub oninvalid="go()">Subscript Text</sub>
onresetThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<sub onreset="go()">Subscript Text</sub>
onselectThe script to be run when some or all of the contents of an object are selected.

 <!-- Executes go() function -->
<sub onselect="go()">Subscript Text</sub>
onsubmitThe script to be run when a form is submitted.

 <!-- Executes go() function -->
<sub onsubmit="go()">Subscript Text</sub>
Keyboard
onkeydownThe script to be run when an element is in focus and keyboard key is pressed down.

 <!-- Executes go() function -->
<sub onkeydown="go()">Subscript Text</sub>
onkeypressThe script to be run when an element is in focus and keyboard key is pressed down and released.

 <!-- Executes go() function -->
<sub onkeypress="go()">Subscript Text</sub>
onkeyupThe script to be run when an element is in focus and keyboard key is released.

 <!-- Executes go() function -->
<sub onkeyup="go()">Subscript Text</sub>
Media
onabortThe script code to be run on abort.

 <!-- Executes go() function -->
<sub onabort="go()">Subscript Text</sub>
oncanplayThe script to be run when a file has buffered enough so it is ready to start playing.

 <!-- Executes go() function -->
<sub oncanplay="go()">Subscript Text</sub>
oncanplaythroughThe script to be run when a file can be played all the way to the end without further need of buffering.

 <!-- Executes go() function -->
<sub oncanplaythrough="go()">Subscript Text</sub>
oncuechangeThe script to be run when the cue changes when using the track element.

 <!-- Executes go() function -->
<sub oncuechange="go()">Subscript Text</sub>
ondurationchangeThe script to be run when the length of the media is changed.

 <!-- Executes go() function -->
<sub ondurationchange="go()">Subscript Text</sub>
onemptiedThe script to be run when a media resource element suddenly becomes empty, usually due to an error.

 <!-- Executes go() function -->
<sub onemptied="go()">Subscript Text</sub>
onendedThe script to be run when the media has reach the end.

 <!-- Executes go() function -->
<sub onended="go()">Subscript Text</sub>
onloadeddataThe script to be run when media data is loaded and playback can start.

 <!-- Executes go() function -->
<sub onloadeddata="go()">Subscript Text</sub>
onloadedmetadataThe script to be run when metadata has been loaded.

 <!-- Executes go() function -->
<sub onloadedmetadata="go()">Subscript Text</sub>
onloadstartThe script to be run whenthe media resource has started loading.

 <!-- Executes go() function -->
<sub onloadstart="go()">Subscript Text</sub>
onpauseThe script to be run when the media resource has been paused.

 <!-- Executes go() function -->
<sub onpause="go()">Subscript Text</sub>
onplayThe script to be run when the media resource starts playback.

 <!-- Executes go() function -->
<sub onplay="go()">Subscript Text</sub>
onplayingThe script to be run when when playback has already begun.

 <!-- Executes go() function -->
<sub onplaying="go()">Subscript Text</sub>
onprogressThe script to be run when the browser is fetching the media data.

 <!-- Executes go() function -->
<sub onprogress="go()">Subscript Text</sub>
onratechangeThe script to be run when the playback rate changes.

 <!-- Executes go() function -->
<sub onratechange="go()">Subscript Text</sub>
onseekedThe script to be run when the seeking attribute is set to false indicating that seeking has finished.

 <!-- Executes go() function -->
<sub onseeked="go()">Subscript Text</sub>
onseekingThe script to be run when the seeking attribute is set to true indicating that seeking is currently active.

 <!-- Executes go() function -->
<sub onseeking="go()">Subscript Text</sub>
onstalledThe script to be run when the browser is unable to continue fetching media data.

 <!-- Executes go() function -->
<sub onstalled="go()">Subscript Text</sub>
onsuspendThe script to be run when media data has stopped before being completely loaded.

 <!-- Executes go() function -->
<sub onsuspend="go()">Subscript Text</sub>
ontimeupdateThe script to be run when the media resources current playback position has changed.

 <!-- Executes go() function -->
<sub ontimeupdate="go()">Subscript Text</sub>
onvolumechangeThe script to be run when the volume has changed or been muted.

 <!-- Executes go() function -->
<sub onvolumechange="go()">Subscript Text</sub>
onwaitingThe script to be run when the media resource has paused but is expected to resume.

 <!-- Executes go() function -->
<sub onwaiting="go()">Subscript Text</sub>
Mouse
onclickThe script to be run when when a mouse is clicked on an element.

 <!-- Executes go() function -->
<sub onclick="go()">Subscript Text</sub>
ondblclickThe script to be run when a mouse is double clicked on an element.

 <!-- Executes go() function -->
<sub ondblclick="go()">Subscript Text</sub>
onmousedownThe script to be run when he mouse button is pressed down while the cursor is over an element.

 <!-- Executes go() function -->
<sub onmousedown="go()">Subscript Text</sub>
onmousemoveThe script to be run when the mouse button is moved.

 <!-- Executes go() function -->
<sub onmousemove="go()">Subscript Text</sub>
onmouseoutThe script to be run when the mouse cursor moves off an element.

 <!-- Executes go() function -->
<sub onmouseout="go()">Subscript Text</sub>
onmouseoverThe script to be run when the mouse cursor moves over an element.

 <!-- Executes go() function -->
<sub onmouseover="go()">Subscript Text</sub>
onmouseupThe script to be run when the mouse button is released while the cursor is over the element.

 <!-- Executes go() function -->
<sub onmouseup="go()">Subscript Text</sub>
onwheelThe script to be run when the mouse wheel rolls up or down over an element.

 <!-- Executes go() function -->
<sub onwheel="go()">Subscript Text</sub>
Scroll
onscrollThe script code to be run when the scrollbar of an element is being scrolled.

 <!-- Executes go() function -->
<sub onscroll="go()">Subscript Text</sub> 
Window - NONE

Relevant HTML Tutorials

HTML Intermediate - More Text Tags