Propriété de style whiteSpace
Exemple
Spécifiez que le texte de l'élément <div> ne sera jamais renvoyé à la ligne :
document.getElementById("myDIV").style.whiteSpace = "nowrap";
Définition et utilisation
La propriété whiteSpace définit ou renvoie comment gérer les tabulations, les sauts de ligne et les espaces dans un texte.
Prise en charge du navigateur
Property | |||||
---|---|---|---|---|---|
whiteSpace | Yes | Yes | Yes | Yes | Yes |
Syntaxe
Renvoyez la propriété whiteSpace :
object.style.whiteSpace
Définissez la propriété whiteSpace :
object.style.whiteSpace = "normal|nowrap|pre|initial|inherit"
Valeurs de propriété
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 |
Détails techniques
Valeur par défaut: | Ordinaire |
---|---|
Valeur de retour : | Une chaîne, représentant la façon dont l'espace blanc à l'intérieur d'un élément est géré |
Version CSS | CSS1 |
Plus d'exemples
Exemple
Renvoie la propriété whiteSpace
alert(document.getElementById("myDiv").style.whiteSpace);
Pages connexes
Tutoriel CSS : Texte CSS
Référence CSS : propriété white-space
❮ Objet de style