Home » Web programming/HTML

HTML Text Formatting

HTML Text Formatting Tags: In HTML, text formatting is used to differentiate the special type of text. In this tutorial, we will learn about different types of text formatting elements used in the HTML programming language.
Submitted by Shivang Yadav, on December 21, 2019

HTML Text Formatting Tags

Text formatting is the process of defining the text in some special type like bold, Italic, underlined, which changes color, etc which make the text special look special as compared to others.

Formatting elements in HTML

HTML provides predefined special elements (tags) for defining these special texts. These are,

Tag Formatting Done
<b> Bold text
<strong> Important text
<i> Italic text
<em> Emphasized text
<mark> Marked text
<small> Small text
<del> Deleted text
<ins> Inserted text
<sub> Subscripted text
<sup> Superscripted text
<u> Underlined text

<b> and <strong> Tags

Both the elements define a bold text but in case of strong a strong importance (semantically) is added to the text.

Example:

<!DOCTYPE html>

<html>

<body>
    <p>I love to learn programming from <b>Include Help</b></p>
    <p>I love to learn programming from <strong>Include Help</strong></p>
</body>

</html>

Output

HTML Text Formatting | Example 1

<i> and <em> Tags

Both the elements define an italic text but in case of emphasized importance (semantically) is added to the text.

Example:

<!DOCTYPE html>

<html>

<body>
    <p>I love to learn programming from <i>Include Help</i></p>
    <p>I love to learn programming from <em>Include Help</em></p>
</body>

</html>

Output

HTML Text Formatting | Example 2

<small> Tag

The small element is used to define text with smaller text as compared to the rest of the text.

Example:

<!DOCTYPE html>

<html>

<body>
    <p>I love to learn programming from <small>Include Help</small></p>
</body>

</html>

Output

HTML Text Formatting | Example 3

<mark> Tag

The mark element is used to define a marked or highlighted text.

Example:

<!DOCTYPE html>

<html>

<body>
    <p>I love to learn programming from <mark>Include Help</mark></p>
</body>

</html>

Output

HTML Text Formatting | Example 4

<del> and <ins> Tags

The del element is used to define text which is deleted or removed from the text.

The ins element is used to define text which is inserted (underlined).

Example:

<!DOCTYPE html>

<html>

<body>
	<p>I love to learn programming from <del>Include Help</del></p>
	<p>I love to learn programming from <ins>Include Help</ins></p>
</body>

</html>

Output

HTML Text Formatting | Example 5

<sub> and <sup> Tags

The sub element is used to define text which is to be written in subscript or below the text.

The sup element is used to define text which is to be written in superscript of the text.

Example:

<!DOCTYPE html>

<html>

<body>
	<p><b>Algebraic formula:</b> (A+B)<sup>2</sup> = A<sup>2</sup> + 2AB + B<sup>2</sup></p>
	<p>The <b>molecular formula for water</b> is H<sub>2</sub>O</p>
</body>

</html>

Output

HTML Text Formatting | Example 6

<u> Tag

The u element is used to define text which is underlined.

Example:

<!DOCTYPE html>

<html>

<body>
    <p>I love to learn programming from <u>Include Help</u></p>
</body>

</html>

Output

HTML Text Formatting | Example 7





Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.