HTML Text Alignment

HTML Text Alignment

HTML Text Alignment

HTML Text alignment is used to align the text on the web page (like left, right, center etc.).

  • HTML Text Alignment is defined by style="text-align:value;" syntax.

  • Value can be (left, right or center).

"By default, the text is aligned on the left side of the web page."

  • It can be used with any HTML element inside Opening tag.


Example:

<p style="text-align:center;">This text align on the center of the web page.</p>

Example Explanation:

In the above, we have shown an example of HTML Center Text Alignment.

  • Center attribute align the text on the center of the Web page.

  • It helps to align the heading on the center which gives the better look of heading on Web Page.

Run the code to see the effect.

Example:

<p style="text-align:right;">This text align on the right side of the web page.</p>

Example Explanation:

In the above, we have shown an example of HTML Center Text Alignment.

  • The right attribute aligns the text on the right of the Web page.

  • It is a very rare attribute that is used in HTML.

Run the code to see the effect.