style.textAlign (Property)

Controls the horizontal alignment of text within the styled element.


CSS level - 1
DOM level - 2
JavaScript - 1.5
JScript - 3.0
Internet Explorer - 4.0
Netscape - 6.0
Property/method value type:String primitive
JavaScript syntax:-myStyle.textAlign
CSS syntax:text-align: anAlignment
Argument list:anAlignmentA style of text alignment to use

Text alignment in the horizontal axis can be controlled with this property. The style.verticalAlign property can be used to align objects vertically with respect to their parents.

The following values are appropriate for this property:

Assigning the center value is equivalent to placing the <CENTER> tags around the text to be center justified. This aligns the text about the center of its width, but leaves the left and right hand sides of the text looking ragged.

The left value lines up the left edge of the text but leaves the right side ragged.

The right value lines up the right side of the text and leaves the left side ragged.

The justify keyword is intended to line up both the left and right sides nice and neatly, using space expansion between words to use up the additional space.


See also:CAPTION.align, JSSTag.textAlign, style.textJustify, style.verticalAlign, style.wordSpacing