Style textDecorationプロパティ
Style オブジェクト
定義と用法
textDecoration プロパティは、テキスト装飾を1つ以上設定または返します。
ヒント:要素に複数の装飾タイプを指定する場合は、スペースで区切ったリストを指定してください。
構文
textDecoration プロパティを設定する:
Object.style.textDecoration="none|underline|overline|line-through|blink|inherit"
textDecoration プロパティを返す:
Object.style.textDecoration
| 值 | 説明 |
|---|---|
| none | デフォルト。標準のテキストを定義します。 |
| underline | テキストの下に線を定義します。 |
| overline | テキストの上に線を定義します。 |
| line-through | テキストを横切る線を定義します。 |
| inherit | textDecoration プロパティの値は親要素から継承されます。 |
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザは textDecoration プロパティをサポートしています。
注意: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.textDecoration="underline overline";
}
</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.textDecoration="underline overline";
}
</script>
</head>
<body>
<p id="p1">これはいくつかのテキストです。</p>
<br>
<button type="button" onclick="displayResult()">テキストを装飾</button>
</body>
</html>
試してみる »
Style オブジェクト その他の拡張機能