Style wordSpacingプロパティ
Style オブジェクト
定義と使い方
wordSpacing プロパティは、テキスト内の単語間のスペースを設定または返します。
構文
wordSpacing プロパティを設定する:
Object.style.wordSpacing="normal|length|inherit"
wordSpacing プロパティを返す:
Object.style.wordSpacing
| 值 | 説明 |
|---|---|
| normal | デフォルト。単語間の標準的なスペースを定義します。 |
| length | px、cm などの単位を使用して単語間のスペースを定義します。負の値も使用できます。 |
| inherit | wordSpacing プロパティの値は親要素から継承されます。 |
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザは wordSpacing プロパティをサポートしています。
注意:IE7 以前のバージョンは "inherit" 値をサポートしていません。IE8 は !DOCTYPE が指定されている場合のみ "inherit" をサポートします。IE9 は "inherit" をサポートします。
例
例
単語間のスペースを変更する:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function displayResult(){
document.getElementById("p1").style.wordSpacing="50px";
}
</script>
</head>
<body>
<p id="p1">これはいくつかのテキストです。</p>
<br>
<button type="button" onclick="displayResult()">修改空间</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function displayResult(){
document.getElementById("p1").style.wordSpacing="50px";
}
</script>
</head>
<body>
<p id="p1">これはいくつかのテキストです。</p>
<br>
<button type="button" onclick="displayResult()">修改空间</button>
</body>
</html>
試してみる »
Style オブジェクト その他の拡張