スタイルwhiteSpaceプロパティ
例
<div>要素のテキストが折り返されないように指定します。
document.getElementById("myDIV").style.whiteSpace = "nowrap";
定義と使用法
whiteSpaceプロパティは、テキスト内のタブ、改行、および空白の処理方法を設定または返します。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
whiteSpace | Yes | Yes | Yes | Yes | Yes |
構文
whiteSpaceプロパティを返します。
object.style.whiteSpace
whiteSpaceプロパティを設定します。
object.style.whiteSpace = "normal|nowrap|pre|initial|inherit"
プロパティ値
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 |
技術的な詳細
デフォルト値: | 正常 |
---|---|
戻り値: | 要素内の空白の処理方法を表す文字列 |
CSSバージョン | CSS1 |
その他の例
例
whiteSpaceプロパティを返します
alert(document.getElementById("myDiv").style.whiteSpace);
関連ページ
CSSチュートリアル:CSSテキスト
CSSリファレンス:空白プロパティ
❮スタイルオブジェクト