HTML Text Formatting

Text formatting in HTML allows you to change the appearance of text by using various tags. HTML provides a set of elements that you can use to modify the display of text, such as making it bold, italic, underlined, and more.

Basic Text Formatting Tags

  • <b>: Makes text bold.
  • <i>: Makes text italicized.
  • <u>: Underlines the text.
  • <strike>: Strikes through the text.
  • <mark>: Highlights the text (typically yellow).

Examples

Here are some examples of text formatting:

<b>Bold Text</b>

Bold Text

<i>Italic Text</i>

Italic Text

<u>Underlined Text</u>

Underlined Text

<strike>Strikethrough Text</strike>

Strikethrough Text

<mark>Highlighted Text</mark>

Highlighted Text

Text Alignment

You can align text to the left, right, or center using the following tags:

  • <p align="left">: Aligns text to the left (default).
  • <p align="right">: Aligns text to the right.
  • <p align="center">: Centers the text.

Example of Text Alignment

<p align="left">Left aligned text</p>

Left aligned text

<p align="right">Right aligned text</p>

Right aligned text

<p align="center">Centered text</p>

Centered text

Line Breaks

To create a line break (new line), use the <br> tag:

<p>Line 1<br>Line 2</p>

Line 1
Line 2

Text Decorations and Styles

HTML provides several tags for text decoration:

  • <small>: Displays smaller text.
  • <del>: Indicates deleted text.
  • <ins>: Indicates inserted text.
  • <q>: Specifies a short inline quotation.

Examples

<small>This is small text</small>

This is small text

<del>Deleted Text</del>

Deleted Text

<ins>Inserted Text</ins>

Inserted Text

<q>This is a quote</q>

This is a quote