The cover of The Complete Idiot's Guide to Create a Web Page The Complete Idiot's Style Sheets Reference

| Index | Current Category: Text |
| Previous Style: table-layout | Next Style: text-decoration |


text-align

Sets the horizontal alignment of text.

Support:

W3C StandardInternet ExplorerNetscape Navigator
CSS1 and later 3.0 and later 4.0 and later
Notes:
  • This style replaces the HTML <P ALIGN> attribute.
Possible Values:
center
Centers the text horizontally.

Support:

W3C StandardInternet ExplorerNetscape Navigator
CSS1 and later 3.0 and later 4.0 and later

justify
Aligns text on both the left and right.

Support:

W3C StandardInternet ExplorerNetscape Navigator
CSS1 and later 4.0 and later 4.0 and later

left
Aligns text on the left.

Support:

W3C StandardInternet ExplorerNetscape Navigator
CSS1 and later 3.0 and later 4.0 and later

right
Aligns text on the right.

Support:

W3C StandardInternet ExplorerNetscape Navigator
CSS1 and later 3.0 and later 4.0 and later

Example:
<TABLE BORDER=1>
<TR>
<TH WIDTH=150>
Left-aligned text
</TH>
<TH WIDTH=150>
Centered text
</TH>
<TH WIDTH=150>
Right-aligned text
</TH>
<TH WIDTH=150>
Justified text
</TH>
</TR>
<TR>
<TD WIDTH=25% STYLE="text-align: left">
Puns are little plays on words that a certain breed of person loves to spring on you and then look at you in a certain 
</TD>
<TD WIDTH=25% STYLE="text-align: center">
self-satisfied way to indicate that he thinks that you must think that he is by far the cleverest person on Earth now 
</TD>
<TD WIDTH=25% STYLE="text-align: right">
that Benjamin Franklin is dead, when in fact what you are thinking is that if this person ever ends up in a lifeboat, 
</TD>
<TD WIDTH=25% STYLE="text-align: justify">
the other passengers will hurl him overboard by the end of the first day even if they have plenty of food and water. —Dave Barry
</TD>
</TR>
</TABLE>
How It Looks:
Left-aligned text Centered text Right-aligned text Justified text
Puns are little plays on words that a certain breed of person loves to spring on you and then look at you in a certain self-satisfied way to indicate that he thinks that you must think that he is by far the cleverest person on Earth now that Benjamin Franklin is dead, when in fact what you are thinking is that if this person ever ends up in a lifeboat, the other passengers will hurl him overboard by the end of the first day even if they have plenty of food and water. —Dave Barry

| Index | Current Category: Text |
| Previous Style: table-layout | Next Style: text-decoration |