Stile whiteSpace Property
Esempio
Specifica che il testo nell'elemento <div> non andrà mai a capo:
document.getElementById("myDIV").style.whiteSpace = "nowrap";
Definizione e utilizzo
La proprietà whiteSpace imposta o restituisce come gestire tabulazioni, interruzioni di riga e spazi bianchi in un testo.
Supporto del browser
Property | |||||
---|---|---|---|---|---|
whiteSpace | Yes | Yes | Yes | Yes | Yes |
Sintassi
Restituisce la proprietà whiteSpace:
object.style.whiteSpace
Imposta la proprietà whiteSpace:
object.style.whiteSpace = "normal|nowrap|pre|initial|inherit"
Valori di proprietà
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 |
Dettagli tecnici
Valore di default: | normale |
---|---|
Valore di ritorno: | Una stringa, che rappresenta il modo in cui viene gestito lo spazio bianco all'interno di un elemento |
Versione CSS | CSS1 |
Altri esempi
Esempio
Restituisce la proprietà whiteSpace
alert(document.getElementById("myDiv").style.whiteSpace);
Pagine correlate
Tutorial CSS: testo CSS
Riferimento CSS: proprietà white-space
❮ Oggetto stile