Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

text-align

Sets whether the text in the object is left-aligned, right-aligned, centered, or justified.

{ text-align: sAlign }

sAlign

String that specifies or receives one of the following values:

left

Default. Text is aligned to the left.

center

Text is centered.

justify

Text is justified.

right

Text is aligned to the right.

The property has a default value of left. It is inherited.

The property applies to block elements. The property is inherited by all block-level objects inside a DIV object.

The following example uses the text-align property to align text within the object. This example uses the P element as a selector and two classes to call an embedded style sheet that aligns the text according to the respective rule:

<style>
    p {text-align:center}
    .align1 {text-align:right}
    .align2 {text-align:justify}
</style>
</head>
<body>
<p onclick= "this.className='align1'" 
    ondblclick="this.className='align2'">
. . . </p>

This example uses inline scripting to change the alignment of the text when an onmouseover event occurs:

<p style="font-size:14" 
    onmouseover="this.style.textAlign='center'">
. . . </p>

BLOCKQUOTE, BODY, CENTER, DD, DIV, DL, DT, FIELDSET, FORM, HN, HR, INPUT TYPE=PASSWORD, INPUT TYPE=TEXT, LI, OL, P, TABLE, TD, TH, TR, UL, XMP

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.