Text Alignment

Text alignment is specified by using the property text-align. It only works on block level elements i.e. the elements that add line break around themselves like h1, p, img etc.

Property Values

The possible values are as follows:

rightIt aligns the text along the right side.
leftDefault value. It aligns the text along the left side.
centerIt aligns the contents to the center within the line box.
justifyIt specifies the text as justify in order to exactly fill the line box.

Text Alignment Example

Below example will demonstrate the basic architecture of Text Alignment

Align text to right
Align text to left
Align text as center
Align text as justify

<!doctype html>  
       <p style="float: center;">Learn CSS from PHPDocs.</p>