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

manuel de référence CSS

règles CSS @

大全 des attributs CSS

Texte CSS-Méthode d'utilisation et exemple de l'attribut align.

text-L'attribut CSS aligne la contenu en ligne (comme du texte et des images) dans l'élément de bloc parent (comme un titre ou un paragraphe) de manière horizontale.

The following table provides usage instructions and version history of this attribute, as well as its usage syntax in JavaScript scripts.

Default value:left ifdirectionis #39; ltr#39; right if direction is #39; rtl#39;
Applies to:Block-level elements, table cells, and inline blocks
Inheritance:Yes
Can be animated:No.Please see Animation attribute.
Version:CSS 1,2,3
JavaScript syntax:
 object.style.textAlign="right"

text-The syntax of align usage

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 see‹/›

Attribute value

The following table describes the value 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-The value of align attribute.

Browser compatibility

text-The compatibility of align attribute in browsers, the numbers in the following table represent the minimum version number of browsers that support this attribute; all mainstream browsers support this attribute.

  • Firefox 1+

  • Google Chrome1+

  • Internet Explorer 3+

  • Apple Safari 1+

  • Opera 3.5+

Read more

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.