スタイルwordSpacingプロパティ
例
<p>要素の単語間のスペースを50ピクセルに設定します。
document.getElementById("myP").style.wordSpacing = "50px";
定義と使用法
wordSpacingプロパティは、テキスト内の単語間の間隔を設定または返します。
ヒント:テキスト内の文字間の間隔を設定または返すには、letterSpacingプロパティを使用します。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
WordSpacing | Yes | Yes | Yes | Yes | Yes |
構文
wordSpacingプロパティを返します。
object.style.wordSpacing
wordSpacingプロパティを設定します。
object.style.wordSpacing = "normal|length|initial|inherit"
プロパティ値
Value | Description |
---|---|
normal | Defines normal spacing between words. This is default |
length | Specifies the space between words in length units. Negative values are allowed |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
技術的な詳細
デフォルト値: | 正常 |
---|---|
戻り値: | テキスト内の単語間のスペースを表す文字列 |
CSSバージョン | CSS1 |
その他の例
例
負の値の使用:
document.getElementById("myP").style.wordSpacing = -3px";
例
<p>要素の単語間隔を返します。
alert(document.getElementById("myP").style.wordSpacing);
例
letterSpacingプロパティとwordSpacingプロパティの違い:
function changeLetters() {
document.getElementById("myP1").style.letterSpacing = "15px";
}
function changeWords() {
document.getElementById("myP2").style.wordSpacing = "15px";
}
関連ページ
CSSチュートリアル:CSSテキスト
CSSリファレンス:word-spacingプロパティ
❮スタイルオブジェクト