Dofactory.com
Dofactory.com
Earn income with your CSS skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

CSS text-align

The text-align property sets the text's horizontal alignment.

Options include left, center, right, and justify.

By default, text is left aligned.

Example

#

An element with text-align set to center.

This text is center aligned

<p style="text-align: center;">
  This text is center aligned
</p>

Syntax

text-align: left | right | center |
            justify | initial | inherit;

Values

#

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.

More Examples

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>

Browser support

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

You may also like


Last updated on Sep 30, 2023

Earn income with your CSS skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides