Home »
HTML
HTML Text Formatting
By IncludeHelp Last updated : October 13, 2024
HTML Text Formatting
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.
HTML Text Formatting Tags
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
<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
<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
<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
<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
<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
<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