• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 4. Text Controls > Aligning Text Left, Right, and Center

Aligning Text Left, Right, and Center

Traditionally, text is either aligned at its left margin or fully justified (often called newspaper style, in which text is aligned at both left and right margins). In addition, for emphasis or special effect, text can be centered on the screen or even right-justified. The text-align property gives you control of the text's alignment and justification (Figure 4.5).

Figure 4.5. Aligning text to the left side, the right side, in the center, or equally on both sides.


To define text alignment:

1.
text-align:

Type the property name, followed by a colon (:), in the CSS definition list (Code 4.5).

Code 4.5. I'm setting up classes for all the various justifications.


Table 4.5. text-align Values
Value Compatibility
left IE3, N4, CSS1
right IE3, N4, CSS1
center IE3, N4, CSS1
justify IE3, N4, CSS1


2.
left;

Set one of the following alignment styles (Table 4.5):

  • left to align the text on the left margin

  • right to align the text on the right margin

  • center to center the text within its area

  • justify to align the text on both the left and right sides

Tip

Fully justifying text may produce some strange results on the screen, because spaces between words must be added to make each line the same length. In addition, there is considerable debate about whether full justification helps or hinders readability.


  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint