Search within TutorialsPark

CSS text-align Property


To position a block of text either to left, right, or center of the page or container element


Definition and Notes.

1. The CSS text-align property is used to control whether the text is aligned to the left or right, center or justified.

2. The default depends upon the user's language, its left if direction is ltr( most lang), its right if direction is rtl (Arabic, Hebrew).

Syntax:

CSS text-align property. internetexplorer safari firefox opera chrome

View in Splitscreen»

Code-Editor:

Note-The text-align does not control the alignment of blocks, it just controls the alignment of text content

Property Values

Value Description
left The inline text is aligned to the left edge of the line box.
right The inline text is aligned to the right edge of the line box
center The inline text is placed at the center of the line box.
justify The text gets justified. The left and right edges of the text are lined up towards the left and right edges of the content box(egual spaces at both ends).
inherit The value of text-align property is inherited from the parent element

Specifications

Specs Value
Name text-align
Value [start | end | left | center | right | justify | match-parent] || <string>
Initial Value left for direction as ltr, and right for direction rtl
Applies to Block-level elements
Javascript syntax object.style.textAlign="center"
Inherited Yes
Computed Value Same as declared value.
Browser Support internetexplorer safari firefox opera chrome


Related Examples.