Propriété CSS text-align
Exemple
Définissez l'alignement du texte pour différents éléments <div> :
div.a {
text-align: center;
}
div.b {
text-align: left;
}
div.c {
text-align: right;
}
div.c {
text-align:
justify;
}
Plus d'exemples "Essayez-le vous-même" ci-dessous.
Définition et utilisation
La text-align
propriété spécifie l'alignement horizontal du texte dans un élément.
Valeur par défaut: | à gauche si la direction est ltr, et à droite si la direction est rtl |
---|---|
Hérité: | Oui |
Animable : | non. En savoir plus sur l'animation |
Version: | CSS1 |
Syntaxe JavaScript : | objet .style.textAlign="right" |
Prise en charge du navigateur
Les nombres dans le tableau indiquent la première version du navigateur qui prend entièrement en charge la propriété.
Property | |||||
---|---|---|---|---|---|
text-align | 1.0 | 3.0 | 1.0 | 1.0 | 3.5 |
Syntaxe CSS
text-align: left|right|center|justify|initial|inherit;
Valeurs de propriété
Value | Description | Play it |
---|---|---|
left | Aligns the text to the left | |
right | Aligns the text to the right | |
center | Centers the text | |
justify | Stretches the lines so that each line has equal width (like in newspapers and magazines) | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
Plus d'exemples
Exemple
Un autre exemple d'alignement de texte :
h1 {
text-align: center;
}
p.date {
text-align: right;
}
p.main {
text-align: justify;
}
Pages connexes
Tutoriel CSS : Texte CSS
Référence HTML DOM : propriété textAlign