text-align

  • Revision slug: CSS/text-align
  • Revision title: text-align
  • Revision id: 11681
  • Created:
  • Creator: Backinblakk
  • Is current revision? No
  • Comment Ported from http://zenit.senecac.on.ca/wiki/index.php/CSS_GUIDE_TEXT_ALIGN

Revision Content

{{template.CSSRef()}}

Summary

The text-align property is used to to describe how lines of text are aligned with each other. Text-align does not control the alignment of elements, only their inline content.

  • Initial value: user-agent specific and can depend on writing direction
  • Applies to: all block level elements
  • Inherited: yes
  • Media: Visual

Syntax

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

Values

  • left : line boxes within the element line up to the left inner content edge of the paragraph
  • right : line boxes within the element line up to the right inner content edge of the paragraph
  • center : line boxes within the element are centered within the content edges of the paragraph
  • justify : line boxes within the element line up their left and right edges to the left and right content edges of the paragraph

Examples

{{template.CSSRefExampleLink("text-align")}}

p.left { text-align: left }

p.right { text-align: right }

Notes

  • CSS2 included a <string> value that was dropped from CSS2.1 due to the lack of implementation.

Specifications

Browser compatibility

Browser Lowest Version
Internet Explorer 3
Netscape 4
Opera 3.5

See also

Revision Source

<p> 
{{template.CSSRef()}}
</p>
<h3 name="Summary"> Summary </h3>
<p>The text-align property is used to to describe how lines of text are aligned with each other.  Text-align does not control the alignment of elements, only their inline content.
</p>
<ul><li> Initial value: user-agent specific and can depend on writing direction
</li><li> Applies to: all block level elements
</li><li> Inherited: yes
</li><li> Media: <a href="en/CSS/Media/Visual">Visual</a>
</li></ul>
<h3 name="Syntax"> Syntax </h3>
<pre class="eval"> text-align: left | center | right | justify | inherit
</pre>
<h3 name="Values"> Values </h3>
<ul><li> <b>left</b> : line boxes within the element line up to the left inner content edge of the paragraph
</li><li> <b>right</b> : line boxes within the element line up to the right inner content edge of the paragraph
</li><li> <b>center</b> : line boxes within the element are centered within the content edges of the paragraph
</li><li> <b>justify</b> : line boxes within the element line up their left and right edges to the left and right content edges of the paragraph
</li></ul>
<h3 name="Examples"> Examples </h3>
<p>{{template.CSSRefExampleLink("text-align")}}
</p>
<pre>p.left { text-align: left }

p.right { text-align: right }
</pre>
<h3 name="Notes"> Notes </h3>
<ul><li> CSS2 included a &lt;string&gt; value that was dropped from CSS2.1 due to the lack of implementation.
</li></ul>
<h3 name="Specifications"> Specifications </h3>
<ul><li> <a class="external" href="http://www.w3.org/TR/CSS1#text-align">CSS 1</a>
</li><li> <a class="external" href="http://www.w3.org/TR/CSS21/text.html#alignment-prop">CSS 2.1</a>
</li></ul>
<h3 name="Browser_compatibility"> Browser compatibility </h3>
<table class="standard-table">
  <tbody><tr>
    <th>Browser</th>
    <th>Lowest Version</th>
  </tr>
  <tr>
    <td>Internet Explorer</td>
    <td>3</td>
  </tr>
  <tr>
    <td>Netscape</td>
    <td>4</td>
  </tr>
  <tr>
    <td>Opera</td>
    <td>3.5</td>
  </tr>
</tbody></table>
<h3 name="See_also"> See also </h3>
Revert to this revision