You are here: Reference > CSS > properties > text-align

text-align property

Browser support:
Specifies the horizontal alignment of the text within the element.
Aligns text only for block elements. It has the same functionality as the align attribute.
JavaScript page for this property: textAlign. You can find other example(s) there.

Possible values:

 One of the following values: 
-moz-center
Text is centered.
-moz-left
Text is aligned to the left.
-moz-right
Text is aligned to the right.
-webkit-auto
Language dependent align rules.
-webkit-center
Text is centered.
-webkit-left
Text is aligned to the left.
-webkit-right
Text is aligned to the right.
center
The text content of the element is centered.
end
Text is aligned to the end of the element's box.
inherit
Takes the value of this property from the computed style of the parent element.
justify
The text content of the element is justified.
left
Aligns the text content of the element to the left.
right
Aligns the text content of the element to the right.
start
Text is aligned the start of the element's box.
Default: left.

Example HTML code 1:

This example illustrates the use of the text-align property:
<head>
    <style>
        .alignLeft {
            text-align: left;
        }
        .alignCenter {
            text-align: center;
        }
        .alignRight {
            text-align: right;
        }
    </style>
</head>
<body>
    <div class="alignLeft">
        Align to left
    </div>
    <div class="alignCenter">
        Align to center
    </div>
    <div class="alignRight">
        Align to right
    </div>
</body>
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content