Style textAlign property
- Página anterior tabSize
- Próxima página textAlignLast
- Voltar para a camada superior Objeto Style HTML DOM
Definition and Usage
textAlign
Sets or returns the horizontal alignment of the text in block-level elements.
See also:
CSS Tutorial:Texto CSS
CSS Reference Manual:text-align property
Example
Example 1
The text in the <p> element is centered:
document.getElementById("myP").style.textAlign = "center";
Example 2
Returns the text alignment of the <p> element:
alert(document.getElementById("myP").style.textAlign);
Syntax
Return textAlign property:
object.style.textAlign
Set textAlign property:
object.style.textAlign = "left|right|center|justify|initial|inherit"
Attribute value
Value | Description |
---|---|
left | Aligns the text to the left. Default. |
right | Aligns the text to the right. |
center | Centers the text. |
justify | The text is adjusted (for left and right alignment). |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical details
Default value: | left |
---|---|
Return value: | String, representing the horizontal alignment of the text within the element. |
Versão do CSS: | CSS1 |
Suporte do navegador
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Suporte | Suporte | Suporte | Suporte | Suporte |
- Página anterior tabSize
- Próxima página textAlignLast
- Voltar para a camada superior Objeto Style HTML DOM