Estilo whiteSpace Propiedad
Ejemplo
Especifique que el texto en el elemento <div> nunca se ajustará:
document.getElementById("myDIV").style.whiteSpace = "nowrap";
Definición y uso
La propiedad whiteSpace establece o devuelve cómo manejar tabulaciones, saltos de línea y espacios en blanco en un texto.
Compatibilidad con navegador
Property | |||||
---|---|---|---|---|---|
whiteSpace | Yes | Yes | Yes | Yes | Yes |
Sintaxis
Devuelve la propiedad whiteSpace:
object.style.whiteSpace
Establezca la propiedad whiteSpace:
object.style.whiteSpace = "normal|nowrap|pre|initial|inherit"
Valores de propiedad
Value | Description |
---|---|
normal | Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary. This is default |
nowrap | Sequences of whitespace will collapse into a single whitespace. Text will never wrap to the next line. The text continues on the same line until a <br> tag is encountered |
pre | Whitespace is preserved by the browser. Text will only wrap on line breaks. Acts like the <pre> tag in HTML |
pre-line | Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary, and on line breaks |
pre-wrap | Whitespace is preserved by the browser. Text will wrap when necessary, and on line breaks |
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: | normal |
---|---|
Valor devuelto: | Una cadena, que representa cómo se maneja el espacio en blanco dentro de un elemento |
Versión CSS | CSS1 |
Más ejemplos
Ejemplo
Devuelve la propiedad whiteSpace
alert(document.getElementById("myDiv").style.whiteSpace);
páginas relacionadas
Tutorial CSS: Texto CSS
Referencia CSS: propiedad de espacio en blanco
❮ Objeto de estilo