Propriedade de alinhamento de texto CSS
Exemplo
Defina o alinhamento do texto para diferentes elementos <div>:
div.a {
text-align: center;
}
div.b {
text-align: left;
}
div.c {
text-align: right;
}
div.c {
text-align:
justify;
}
Mais exemplos de "Experimente você mesmo" abaixo.
Definição e uso
A text-align
propriedade especifica o alinhamento horizontal do texto em um elemento.
Valor padrão: | esquerda se a direção for ltr, e direita se a direção for rtl |
---|---|
Herdado: | sim |
Animavel: | não. Leia sobre animáveis |
Versão: | CSS1 |
Sintaxe JavaScript: | objeto .style.textAlign="right" |
Suporte ao navegador
Os números na tabela especificam a primeira versão do navegador que oferece suporte total à propriedade.
Property | |||||
---|---|---|---|---|---|
text-align | 1.0 | 3.0 | 1.0 | 1.0 | 3.5 |
Sintaxe CSS
text-align: left|right|center|justify|initial|inherit;
Valores de propriedade
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 |
Mais exemplos
Exemplo
Outro exemplo de alinhamento de texto:
h1 {
text-align: center;
}
p.date {
text-align: right;
}
p.main {
text-align: justify;
}
Páginas relacionadas
Tutorial CSS: Texto CSS
Referência HTML DOM: propriedade textAlign