Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

CSS Dictionary

  1. Home
  2. CSS Dictionary
  3. text-align

text-align

Specifies the alignment position for inline content such as inline-level elements.

Sample Code

p.test { text-align: left;}
p.test1 { text-align: right;}
p.test2 { text-align: center;}

Available Values

ValueDescription
startFor languages read left-to-right (such as Japanese or English), the rendering is the same as 'left'; for languages read right-to-left, the rendering is the same as 'right'. This 'start' is the initial value.
leftAligns content to the left.
rightAligns content to the right.
centerAligns content to the center.

Browser Display Result

<p style="border: solid 1px black; text-align: left;">This is a p element.</p>

<p style="border: solid 1px black; text-align: right;">This is a p element.</p>

<p style="border: solid 1px black; text-align: center;">This is a p element.</p>

Browser Compatibility

Chrome Chrome
1+
Firefox Firefox
1+
Safari Safari
1+
Edge Edge
12+
Supported in all versions
IE IE
11
10
9
8
7
6
Opera Opera
3.5+
2 and earlier ×
iOS Safari iOS Safari
1+
Android Android Browser
4.4+
3 and earlier ×
Chrome Android Chrome Android
Latest
Same support as desktop
Firefox Android Firefox Android
Latest
Same support as desktop

※ Version data is based on MDN.

Details

Specifies the alignment position for inline content such as inline-level elements.

Note that alignment can only be applied to inline content such as inline-level elements (span, img, etc.). To position block-level elements or table elements, use the 'margin' property instead.

<div style="border: solid 1px black; text-align: center;">
	<p style="background-color: yellow; width: 300px; margin: 0;">This is a p element with a width of 300px. Although 'text-align: center' is specified on the parent div element, this p element is a block-level element so it is not centered. However, this text inside the p element is inline content, so it is displayed centered.</p>
</div>

<div style="border: solid 1px black;">
	<p style="background-color: yellow; width: 300px; margin: 0 auto;">This is a p element with a width of 300px. 'margin: 0 auto' is specified on the p element to center it.</p>
</div>

If you find any errors or copyright issues, please .