Propriedade do espaço em branco do estilo
Exemplo
Especifique que o texto no elemento <div> nunca será quebrado:
document.getElementById("myDIV").style.whiteSpace = "nowrap";
Definição e uso
A propriedade whiteSpace define ou retorna como lidar com tabulações, quebras de linha e espaços em branco em um texto.
Suporte ao navegador
Property | |||||
---|---|---|---|---|---|
whiteSpace | Yes | Yes | Yes | Yes | Yes |
Sintaxe
Retorne a propriedade whiteSpace:
object.style.whiteSpace
Defina a propriedade whiteSpace:
object.style.whiteSpace = "normal|nowrap|pre|initial|inherit"
Valores de propriedade
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 |
Detalhes técnicos
Valor padrão: | normal |
---|---|
Valor de retorno: | Uma String, representando como o espaço em branco dentro de um elemento é tratado |
Versão CSS | CSS1 |
Mais exemplos
Exemplo
Retorne a propriedade whiteSpace
alert(document.getElementById("myDiv").style.whiteSpace);
Páginas relacionadas
Tutorial CSS: Texto CSS
Referência CSS: propriedade de espaço em branco
❮ Objeto de estilo