text-align (CSS property)
Example
This style rule makes text in
h1 headings centered:
h1 {
text-align: center;
}
Description
This property specifies how the inline content of a block is aligned, when the sum of the widths of the inline boxes is less than the width of the line box.
Value
The initial value is
left if direction is
ltr, and right if
direction is rtl.
center- This value makes the text center justified.
justify- This value makes the text left and right justified. In this
case, inline boxes may be stretched in addition to being
repositioned. If
white-spaceispreorpre-line, the alignment is set to the initial value. left- This value makes the text left justified.
right- This value makes the text right justified.
Compatibility
| IE | 5.5 | Buggy |
|---|---|---|
| 6.0 | Buggy | |
| 7.0 | Buggy | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | Full |
| 2.0 | Full | |
| 3.0 | Full | |
| Opera | 9.2 | Full |
| 9.5 | Full |
Internet Explorer for
Windows versions up to and including 7 incorrectly align block-level boxes
according to the text-align property, although it
should only affect inline boxes. The value justify
behaves like center for table caption boxes.
Internet Explorer for Windows versions up to and
including 7 don’t support the value inherit.
User-contributed notes
- ID:
- #3
- Date:
- Tue, 22 Apr 2008 13:03:52 GMT
- Status:
- This note has not yet been confirmed for accuracy and relevance.
@sebwin: Not according to the CSS2.1 specification <http://www.w3.org/TR/CSS21/text.html#propdef-text-align>.
It was in CSS2, but that option was removed in CSS2.1 since no user agent implemented it.
- ID:
- #2
- Date:
- Thu, 17 Apr 2008 09:54:54 GMT
- Status:
- This note has not yet been confirmed for accuracy and relevance.
For table cells specifying a string value is also permitted.
Compatibility information would be helpful here…
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

