HTML contains several elements for defining text with a special meaning.
HTML Formatting is a process of formatting text for better look and feel. HTML provides us ability to format text without using CSS. There are many formatting tags in HTML. These tags are used to make text bold, italicized, or underlined. There are almost 14 options available that how text appears in HTML and XHTML.
In HTML the formatting tags are divided into two categories:
NOTE: There are some physical and logical tags which may give same visual appearance, but they will be different in semantics.
Here, we are going to learn 14 HTML formatting tags. Following is the list of HTML formatting text.
Element name | Description |
---|---|
<b> | This is a physical tag, which is used to bold the text written between it. |
<strong> | This is a logical tag, which tells the browser that the text is important. |
<i> | This is a physical tag which is used to make text italic. |
<em> | This is a logical tag which is used to display content in italic. |
<mark> | This tag is used to highlight text. |
<u> | This tag is used to underline text written between it. |
<tt> | This tag is used to appear a text in teletype. (not supported in HTML5) |
<strike> | This tag is used to draw a strikethrough on a section of text. (Not supported in HTML5) |
<sup> | It displays the content slightly above the normal line. |
<sub> | It displays the content slightly below the normal line. |
<del> | This tag is used to display the deleted content. |
<ins> | This tag displays the content which is added |
<big> | This tag is used to increase the font size by one conventional unit. |
<small> | This tag is used to decrease the font size by one unit from base font size. |
<p><b>This text is bold</b></p>
<p><i>This text is italic</i></p>
<p>This is<sub> subscript</sub> and <sup>superscript</sup></p>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p><b>This text is bold</b></p>
<p><i>This text is italic</i></p>
<p>This is<sub> subscript</sub> and <sup>superscript</sup></p>
</body>
</html>
Formatting elements were designed to display special types of text:
<b>
- Bold text<strong>
- Important text<i>
- Italic text<em>
- Emphasized text<mark>
- Marked text<small>
- Smaller text<del>
- Deleted text<ins>
- Inserted text<sub>
- Subscript text<sup>
- Superscript textThe HTML <b>
element defines bold text, without any extra importance.
<p>This text is normal.</p>
<p><b>This text is bold.</b></p>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p>This text is normal.</p>
<p><b>This text is bold.</b></p>
</body>
</html>
The HTML <strong>
element defines text with strong importance. The content inside is typically displayed in bold.
<p>This text is normal.</p>
<p><strong>This text is important!</strong></p>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p>This text is normal.</p>
<p><strong>This text is important!</strong></p>
</body>
</html>
The HTML <i>
element defines a part of text in an alternate voice or mood. The content inside is typically displayed in italic.
Tip: The <i>
tag is often used to indicate a technical term, a phrase from another language, a thought, a ship name, etc.
<p>This text is normal.</p>
<p><i>This text is italic.</i></p>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p>This text is normal.</p>
<p><i>This text is italic.</i></p>
</body>
</html>
The HTML <em>
element defines emphasized text. The content inside is typically displayed in italic.
Tip: A screen reader will pronounce the words in <em>
with an emphasis, using verbal stress.
Example:
HTML
<p>This text is normal.</p>
<p><em>This text is emphasized.</em></p>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p>This text is normal.</p>
<p><em>This text is emphasized.</em></p>
</body>
</html>
The HTML <small>
element defines smaller text:
<p><small>This is some smaller text.</small></p>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p>This is some normal text.</p>
<p><small>This is some smaller text.</small></p>
</body>
</html>
The HTML <mark>
element defines text that should be marked or highlighted:
<mark>milk</mark>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p>Do not forget to buy <mark>milk</mark> today.</p>
</body>
</html>
The HTML <del>
element defines text that has been deleted from a document. Browsers will usually strike a line through deleted text:
<del>blue</del>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p>My favorite color is <del>blue</del> red.</p>
</body>
</html>
The HTML <ins>
element defines a text that has been inserted into a document. Browsers will usually underline inserted text:
<ins>red</ins>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p>My favorite color is <del>blue</del> <ins>red</ins>.</p>
</body>
</html>
The HTML <sub>
element defines subscript text. Subscript text appears half a character below the normal line, and is sometimes rendered in a smaller font. Subscript text can be used for chemical formulas, like H2O:
<p>This is <sub>subscripted</sub> text.</p>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p>This is <sub>subscripted</sub> text.</p>
</body>
</html>
The HTML <sup>
element defines superscript text. Superscript text appears half a character above the normal line, and is sometimes rendered in a smaller font. Superscript text can be used for footnotes, like WWW[1]:
<p>This is <sup>superscripted</sup> text.</p>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p>This is <sup>superscripted</sup> text.</p>
</body>
</html>