Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/myscript/public_html/classes/classdb.php on line 42
CSS (HTML) Tutorial - Aligning text to left or right or center using style sheet

CSS Text Alignment

How to align the text to right in html using css?
How to position the text?

Explanation

Property :

Text Alignment

Usage:


text-align: center;
text-align: left;
text-align: right;
text-align: justify;

Definition:

This will align the text with in the object area.
It takes the following values.
a)center : This value aligns the text to center.
b)left : This value aligns the text to left.
c)right : This value aligns the text to right.
d)justify : This justifies the text with default value.

Example 1:


<div style="text-align: center;">testing text align</div>
Result:

testing text align

Example 2:


<div style="text-align: left;">testing text align</div>
Result:

testing text align


Example 3:


<div style="text-align: right;">testing text align</div>
Result:

testing text align


Example 4:


<div style="text-align: justify;">testing text align</div>
Result:

testing text align

Ask Questions

Ask Question