Estilo textAlign Propiedad
Ejemplo
Alinear al centro el texto en un elemento:
document.getElementById("demo").style.textAlign = "center";
Definición y uso
La propiedad textAlign establece o devuelve la alineación horizontal del texto en un elemento de nivel de bloque.
Compatibilidad con navegador
Property | |||||
---|---|---|---|---|---|
textAlign | Yes | Yes | Yes | Yes | Yes |
Sintaxis
Devuelve la propiedad textAlign:
object.style.textAlign
Establezca la propiedad textAlign:
object.style.textAlign = "left|right|center|justify|initial|inherit"
Valores de propiedad
Value | Description |
---|---|
left | Aligns the text to the left. This is default |
right | Aligns the text to the right |
center | Centers the text |
justify | The text is justified |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Detalles técnicos
Valor por defecto: | izquierda |
---|---|
Valor devuelto: | Una cadena, que representa la alineación horizontal del texto dentro del elemento. |
Versión CSS | CSS1 |
Más ejemplos
Ejemplo
Devuelve la alineación del texto de un elemento:
alert(document.getElementById("demo").style.textAlign);
páginas relacionadas
Tutorial CSS: Texto CSS
Referencia CSS: propiedad de alineación de texto
❮ Objeto de estilo