Styl whiteSpace Property
Przykład
Określ, że tekst w elemencie <div> nigdy nie będzie zawijany:
document.getElementById("myDIV").style.whiteSpace = "nowrap";
Definicja i użycie
Właściwość whiteSpace ustawia lub zwraca sposób obsługi tabulatorów, łamania wierszy i białych znaków w tekście.
Obsługa przeglądarki
Property | |||||
---|---|---|---|---|---|
whiteSpace | Yes | Yes | Yes | Yes | Yes |
Składnia
Zwróć właściwość whiteSpace:
object.style.whiteSpace
Ustaw właściwość whiteSpace:
object.style.whiteSpace = "normal|nowrap|pre|initial|inherit"
Wartości nieruchomości
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 |
Szczegóły techniczne
Domyślna wartość: | normalna |
---|---|
Wartość zwrotu: | String, reprezentujący sposób obsługi białych znaków wewnątrz elementu |
Wersja CSS | CSS1 |
Więcej przykładów
Przykład
Zwróć właściwość whiteSpace
alert(document.getElementById("myDiv").style.whiteSpace);
Powiązane strony
Samouczek CSS: Tekst CSS
Odniesienie CSS: właściwość white-space
❮ Obiekt stylu