w3resource

HTML sub tag and element

1. HTML sub (stands for subscript) element defines a text to be subscripted.

2. A typical example of using sub element is, when you want to display 2 and 4 in H2SO4.

Syntax

<sub>text content</sub> 

Category

HTML sub element is an Inline element.

Whether both start and end tags are required

Yes.

Can contain

HTML sub element can contain inline elements.

Can reside within

HTML sub element can reside within inline as well as block level elements.

Attributes

Attributes specific to this element

None.

Identifiers

id, class.

language information and text direction

lang, dir.

Title

Title.

Style

Style.

Events

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup.

Supported doctypes

HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset.

Example of using HTML sub element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>html sub tag example</title>
</head>
<body>
<p>Symbol of Sulphuric Acid is H<sub>2</sub>SO<sub>4.</p>
</body>
</html>

Result

html sub element

View this example in a separate browser window

HTML sub tag example.

Pictorial presentation

sub-example

Previous: HTML q tag and element
Next: HTML sup tag and element

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/html/sub/HTML-sub-tag-and-element.php