Lesson 6 of 21 – HTML Formatting
30%
30%

HTML Formatting

HTML formatting elements help to style and format the content of a webpage. These tags improve readability and make important information stand out.

Definition: HTML formatting tags are used to display text in different styles such as bold, italic, underline, highlighted text, superscript, subscript, and more.

1. Bold Text

The <b> and <strong> tags make text bold.

<b>Bold Text</b>
<strong>Important Text</strong>

2. Italic Text

The <i> and <em> tags display text in italic style.

<i>Italic Text</i>
<em>Emphasized Text</em>

3. Underline Text

The <u> tag is used to underline text.

<u>Underlined Text</u>

4. Strikethrough Text

The <s> and <del> tags display text with a line through it.

<s>Old Price</s>
<del>Deleted Text</del>

5. Subscript Text

The <sub> tag defines subscript text.

H<sub>2</sub>O

Output: H₂O

6. Superscript Text

The <sup> tag defines superscript text.

X<sup>2</sup>

Output:

7. Inserted Text

The <ins> tag defines inserted text.

<ins>Inserted Text</ins>

8. Deleted Text

The <del> tag defines deleted text.

<del>Deleted Text</del>

9. Small Text

The <small> tag displays smaller text.

<small>Small Text</small>

10. Code Text

The <code> tag is used for programming code.

<code>echo "Hello World";</code>

11. Keyboard Input

The <kbd> tag defines keyboard input.

<kbd>Ctrl + C</kbd>

12. Preformatted Text

The <pre> tag preserves spaces and line breaks.

<pre>
Line 1
    Line 2
        Line 3
</pre>

13. Block Quotation

The <blockquote> tag is used for long quotations.

<blockquote>
Knowledge is power.
</blockquote>

14. Highlighted Text

The <mark> tag highlights important text.

<mark>Highlighted Text</mark>

Summary of Formatting Tags

Tag Purpose
<b>Bold Text
<strong>Important Bold Text
<i>Italic Text
<em>Emphasized Text
<u>Underline Text
<s>Strikethrough Text
<sub>Subscript Text
<sup>Superscript Text
<small>Small Text
<mark>Highlight Text
<code>Programming Code
<kbd>Keyboard Input
<pre>Preformatted Text
<blockquote>Quotation

Key Points

  • Formatting tags improve the appearance of webpage content.
  • <strong> and <b> make text bold.
  • <em> and <i> make text italic.
  • <mark> highlights important text.
  • <sub> and <sup> are useful in science and mathematics.
  • <code> and <pre> help display programming code.
💡 Remember: HTML formatting tags help make web content attractive, readable, and meaningful.

🧠 Quiz

Which tag is used to highlight text in HTML?