CSS text-align Property
CSS text-align
property sets the horizontal alignment of the text element within its parent block element.
Usages
The following table outline the usages and version history of this property.
Default value: | left if direction is ltr right if direction is rtl |
Applies to: | All block level elements, table cells, and inline-blocks |
Inherited: | Yes |
Version: | CSS1 |
JavaScript Syntax: | object.style.textAlign = "center" |
Syntax
Here is a syntax for the CSS text-align
property
text-align: left | right | center | justify | initial | inherit;
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
left | text are sets left aligned |
right | text are sets right aligned |
center | text are sets center aligned |
justify | text are set justified aligned (set equal width lines), same as like in newspapers, magazines |
initial | Sets default value of this property |
inherit | Inherits this property from its parent element |
Examples
The example below shows to sets text align values of the element.
p.one {
text-align: left;
}
p.two {
text-align: right;;
}
p.three {
text-align: center;
}
p.four {
text-align: justify;
}
Browser Compatibility
- Google Chrome 1+
- Mozilla Firefox 1+
- Internet Explorer 3+
- Opera 3.5+
- Safari 1+
Note: Here details of browser compatibility with version number may be this is bug and not supported. But recommended to always use latest Web browser.