text-decoration
文字
下線や取り消し線を付けます。リンクの既定の下線を消すときにも使います。
| 書き方 | text-decoration: none; |
|---|---|
| よく使う値 | none, underline, line-through |
| 継承 | いいえ — この要素で止まります |
| まとめて決めるもの | text-decoration-line, text-decoration-color, text-decoration-style |
| 分類 | 文字 |
読み方
- 継承する属性は親に一度書けば子がすべて受け継ぎます。文字に関する属性はたいていそうです。
- 一括指定は書かなかった値を既定に戻します。background: red だけ書くと、先に入れた背景画像も一緒に消えます。
- 同じ要素で規則がぶつかると、より具体的なセレクターが勝ちます。具体性が同じときにだけ後に書いたほうが勝ちます。
- 動きはtransformとopacityで作るとなめらかです。widthやtopを変えるとレイアウトを計算し直すことになります。
よくある質問
Q. CSSの text-decoration プロパティとは何ですか。
下線や取り消し線を付けます。リンクの既定の下線を消すときにも使います。
Q. text-decoration はどう書きますか。
text-decoration: none; のように書きます。よく使う値は none、underline、line-through などです。
Q. text-decoration は継承しますか。
継承しません。必要な要素ごとに書く必要があります。
Q. text-decoration は何をまとめて決めますか。
text-decoration-line、text-decoration-color、text-decoration-styleをまとめて決めます。書かなかった値は既定に戻ります。