Stijl witSpace Property
Voorbeeld
Geef op dat de tekst in het <div>-element nooit terugloopt:
document.getElementById("myDIV").style.whiteSpace = "nowrap";
Definitie en gebruik
De eigenschap whiteSpace bepaalt of geeft terug hoe tabs, regeleinden en witruimte in een tekst moeten worden verwerkt.
Browserondersteuning
Property | |||||
---|---|---|---|---|---|
whiteSpace | Yes | Yes | Yes | Yes | Yes |
Syntaxis
Retourneer de eigenschap whiteSpace:
object.style.whiteSpace
Stel de eigenschap whiteSpace in:
object.style.whiteSpace = "normal|nowrap|pre|initial|inherit"
Eigendomswaarden
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 |
Technische details
Standaardwaarde: | normaal |
---|---|
Winstwaarde: | Een tekenreeks, die aangeeft hoe witruimte binnen een element wordt verwerkt |
CSS-versie | CSS1 |
Meer voorbeelden
Voorbeeld
Retourneer de eigenschap whiteSpace
alert(document.getElementById("myDiv").style.whiteSpace);
Gerelateerde pagina's
CSS-zelfstudie: CSS-tekst
CSS -referentie: eigenschap witruimte
❮ Stijlobject