Easy Tutorial
❮ Prop Video Src Prop Audio Volume ❯

Style textAlign Property


Definition and Usage

The textAlign property sets or returns the horizontal alignment of text within a block-level element.

Syntax

Setting the textAlign property:

Returning the textAlign property:

Value Description
left Default. Aligns the text to the left.
right Aligns the text to the right.
center Aligns the text to the center.
justify Aligns the text according to the textJustify property.
inherit The value of the textAlign property is inherited from the parent element.

Browser Support

All major browsers support the textAlign property.

Note: IE7 and earlier versions do not support the "inherit" value. IE8 only supports "inherit" if the !DOCTYPE is specified. IE9 supports "inherit".


Example

Aligning the text in a p element to the center:

❮ Prop Video Src Prop Audio Volume ❯