Easy Tutorial
❮ Pr Border Top Color Func Min ❯

CSS text-align Property

Example

Set the text alignment for h1, h2, and h3 elements:

h1 {text-align:center}
h2 {text-align:left}
h3 {text-align:right}

Property Definition and Usage

The text-align property specifies the horizontal alignment of text in an element.

Default value: If the direction property is ltr, the default value is left; if the direction property is rtl, the default value is right.
Inherited: yes
--- ---
Version: CSS1
--- ---
JavaScript syntax: object.style.textAlign="right"
--- ---

Browser Support

The numbers in the table specify the first browser version that fully supports the property.

The numbers preceding -webkit-, -ms-, or -moz- indicate the first browser version that supports the prefixed property.

Property
text-align 1.0 3.0 1.0 1.0 3.5

Property Values

Value Description
left Aligns the text to the left. Default value: determined by the browser.
right Aligns the text to the right.
center Aligns the text to the center.
justify Achieves a justified text effect.
inherit Specifies that the value of the text-align property should be inherited from the parent element.

More Examples

More advanced text alignment examples


Related Articles

CSS Tutorial: CSS Text

❮ Pr Border Top Color Func Min ❯