Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

CSS text-align property


May 06, 2021 CSS Reference Manual


Table of contents


CSS text-align property


H1, h2, and h3 elements set the alignment of text:

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

Try it out . . .

There are more examples at the bottom of this page.

Description of property definition and use

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

Default: left if direction is ltr, and right if direction is rtl
Inherited: yes
Version: CSS1
JavaScript syntax: object.style.textAlign="right"


Browser support

The numbers in the table support the first browser version number of the property.

The number immediately before -webkit-, -ms- or -moz- is the first browser version number that supports the prefix property.

Attributes
text-align 1.0 3.0 1.0 1.0 3.5

The property value

Value Describe
left Arrange the text to the left. Default: It's up to the browser.
right Arrange the text to the right.
center Arrange the text into the middle.
justify The text effect is achieved with both ends aligned.
inherit Specifies that the value of the text-align property should be inherited from the parent element.


CSS text-align property

More instances

More examples of advanced text alignment
This example demonstrates a more advanced example of text alignment.


Related articles

CSS tutorial: CSS text