Vlastnost stylu whiteSpace
Příklad
Určete, že text v prvku <div> se nikdy nezalamuje:
document.getElementById("myDIV").style.whiteSpace = "nowrap";
Definice a použití
Vlastnost whiteSpace nastavuje nebo vrací, jak zacházet s tabulátory, zalomením řádků a mezerami v textu.
Podpora prohlížeče
Property | |||||
---|---|---|---|---|---|
whiteSpace | Yes | Yes | Yes | Yes | Yes |
Syntax
Vraťte vlastnost whiteSpace:
object.style.whiteSpace
Nastavte vlastnost whiteSpace:
object.style.whiteSpace = "normal|nowrap|pre|initial|inherit"
Hodnoty vlastností
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 |
Technické údaje
Výchozí hodnota: | normální |
---|---|
Návratová hodnota: | Řetězec představující, jak se zachází s bílými místy uvnitř prvku |
Verze CSS | CSS1 |
Další příklady
Příklad
Vraťte vlastnost whiteSpace
alert(document.getElementById("myDiv").style.whiteSpace);
Související stránky
CSS tutoriál: CSS Text
CSS reference: vlastnost white-space
❮ Objekt stylu