TECH I.S.

CSS テキスト装飾


テキスト装飾

この章では、次のプロパティについて学習します。

  • text-decoration-line
  • text-decoration-color
  • text-decoration-style
  • text-decoration-thickness
  • text-decoration

テキストに装飾線を追加する

text-decoration-lineプロパティは、テキストに装飾線を追加するために使用されます。

ヒント:上線と下線のように、複数の値を組み合わせて、テキストの上と下の両方に線を表示できます。

h1 {   text-decoration-line: overline; } h2 {   text-decoration-line: line-through; } h3 {   text-decoration-line: underline; } p {   text-decoration-line: overline underline; }

自分で試してみる »

ノート:リンクではないテキストに下線を引くことは、読者を混乱させることが多いため、お勧めしません。


飾り線の色を指定する

text-decoration-colorプロパティを使用して装飾線の色を設定します。

h1 {   text-decoration-line: overline;   text-decoration-color: red; } h2 {   text-decoration-line: line-through;   text-decoration-color: blue; } h3 {   text-decoration-line: underline;   text-decoration-color: green; } p {   text-decoration-line: overline underline;   text-decoration-color: purple; }

自分で試してみる »


装飾線のスタイルを指定する

text-decoration-styleプロパティは装飾線のスタイルを設定するために使用されます。

h1 {   text-decoration-line: underline;   text-decoration-style: solid; } h2 {   text-decoration-line: underline;   text-decoration-style: double; } h3 {   text-decoration-line: underline;   text-decoration-style: dotted; } p.ex1 {   text-decoration-line: underline;   text-decoration-style: dashed; } p.ex2 {   text-decoration-line: underline;   text-decoration-style: wavy; } p.ex3 {   text-decoration-line: underline;   text-decoration-color: red;   text-decoration-style: wavy; }

自分で試してみる »


飾り線の太さを指定する

text-decoration-thicknessプロパティを使用して装飾線の太さを設定します。

h1 {   text-decoration-line: underline;   text-decoration-thickness: auto; } h2 {   text-decoration-line: underline;   text-decoration-thickness: 5px; } h3 {   text-decoration-line: underline;   text-decoration-thickness: 25%; } p {   text-decoration-line: underline;   text-decoration-color: red;   text-decoration-style: double;   text-decoration-thickness: 5px; }

自分で試してみる »


省略形プロパティ

text-decorationプロパティは、次の省略形のプロパティです。

  • text-decoration-line(必要)
  • text-decoration-color(オプション)
  • text-decoration-style(オプション)
  • text-decoration-thickness(オプション)

h1 {   text-decoration: underline; } h2 {   text-decoration: underline red; } h3 {   text-decoration: underline red double; } p {   text-decoration: underline red double 5px; }

自分で試してみる »


小さなヒント

HTML 内のすべてのリンクには、デフォルトで下線が引かれています。リンクが下線のないスタイルになっていることがあります。のtext-decoration: none;次のように、リンクから下線を削除するために使用されます。

a {   text-decoration: none; }

自分で試してみる »


すべての CSS テキスト装飾プロパティ

財産

説明

テキスト装飾 1 つの宣言ですべてのテキスト装飾プロパティを設定します
文字装飾色 テキスト装飾の色を指定します
テキスト装飾線 使用するテキスト装飾の種類を指定します (下線、上線、 等。)
テキスト装飾スタイル テキスト装飾のスタイルを指定します (実線、点線など)。
文字装飾の太さ 文字飾り線の太さを指定します


プログラミング学習を加速させる

プログラミングをプロの講師に教えてもらいませんか。

テックアイエスのプログラミングスクールは初心者も大歓迎です。年齢制限もありません。転職・副業に強く、挫折させない手厚いサポートで稼ぐ力を身につけましょう!

スクールの詳細