English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules (RULES)

Complete List of CSS Attributes

CSS text-Usage and examples of the 'align' property

text-The CSS 'align' property sets the horizontal alignment of inline content (such as text and images) within its parent block element (such as a heading or paragraph).

下表为此属性的用法说明和版本历史记录,以及该属性在javascript脚本中的使用语法。

The following table provides usage instructions and version history of this attribute, as well as its usage syntax in JavaScript scripts.Default Value:left ifdirection39; is #39; ltr#39; right if direction is #39; rtl#
;Applicable To:
Block-level elements, table cells, and inline blocksInheritance:
YesAnimatable:No. Animation Attribute.
Version:CSS 1,2,3
JavaScript Syntax:
 object.style.textAlign="right"

text-align Usage Syntax

The syntax of this attribute is as follows:

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

The following example demonstrates how to use text-align Attribute.

  h1 {
   text-align: center;
  }
  p {
   text-align: justify;
  }
Test to see‹/›

Attribute Values

The following table describes the values of this attribute.

ValueDescription
leftAlign inline text to the left.
rightAlign inline text to the right.
centerCenter inline text.
justifyText makes sense. Text aligns its left and right edges to the left and right content edges of the paragraph by stretching spaces and words.
initialSet this attribute to its default value.
inheritIf specified, the associated elements adopt the text of their parent element.-align Attribute Values.

Browser Compatibility

text-Browser Compatibility of align Attribute, the numbers in the table below represent the minimum version number of the browser that supports this attribute; all mainstream browsers support this attribute.

  • Firefox 1+

  • Google Chrome1+

  • Internet Explorer 3+

  • Apple Safari 1+

  • Opera 3.5+

Further Reading

Please refer to the following tutorials:CSS Text,CSS Alignment.

Text-related Attributes:letter-spacing,text-decoration,text-indent,text-overflow,text-shadow,text-transform,white-space,word-spacing.