The text-align property sets the text's horizontal alignment.
Options include left, center, right, and justify.
By default, text is left aligned.
An element with text-align set to center.
This text is center aligned
<p style="text-align: center;">
This text is center aligned
</p>
text-align: left | right | center |
justify | initial | inherit;
| Value | Description |
|---|---|
| left | Left align text |
| right | Right align text |
| center | Center align text |
| justify | Justifies text making each line equal width |
| initial | Sets the value to its default value value. |
| inherit | Inherits the value from its parent element. |
Click the buttons to see the different text-align values.
This text is right aligned
<style>
.align-example {
text-align: right;
}
</style>
<p class="align-example">
This text is right aligned
</p>
This table shows when text-align support started for each browser.
![]() Chrome
|
1.0 | Dec 2008 |
![]() Firefox
|
1.0 | Nov 2004 |
![]() IE/Edge
|
3.0 | Aug 1996 |
![]() Opera
|
3.5 | Nov 1998 |
![]() Safari
|
1.0 | Jun 2003 |