HTML スタイル

❮ 前章へ 次章へ ❯

I am Red

I am Blue

I am Big


Try it Yourself ❯

HTML Style 属性

HTML 要素にスタイルを設定するには、style 属性を使用します。

HTML style 属性の構文は次の通りです:

<tagname style="property:value;">

property は、CSS のプロパティです。value は、CSS の値です。

このチュートリアルの後段で CSS を詳しく学習します。


HTML 背景色

background-color プロパティは、HTML 要素の背景色を定義します。

下の例では、ページの背景色に powderblue を設定しています:

<body style="background-color:powderblue;">

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
Try it Yourself »

HTML テキスト色

color プロパティは、HTML 要素に使用するテキストの色を定義します:

<body>
  <h1 style="color:blue">This is a heading</h1>
  <p style="color:red">This is a paragraph.</p>
</body>

Try it Yourself ❯

HTML フォント

font-family プロパティは、HTML 要素に使用するフォントを定義します:

<body>
  <h1 style="font-family:verdana">This is a heading</h1>
  <p style="font-family:courier">This is a paragraph.</p>
</body>

Try it Yourself ❯

HTML テキストサイズ

font-size プロパティは、HTML 要素に使用するテキストのサイズを定義します:

<body>
  <h1 style="font-size:300%">This is a heading</h1>
  <p style="font-size:160%">This is a paragraph.</p>
</body>

Try it Yourself ❯

HTML テキストの配置

text-align プロパティは、HTML 要素の横方向のテキストの配置を定義します:

<body>
  <h1 style="text-align:center">Centered Heading</h1>
  <p>This is a paragraph.</p>
</body>

Try it Yourself ❯

この章のまとめ


練習問題を自分でテストしてください!

Exercise 1 ❯  Exercise 2 ❯  Exercise 3 ❯  Exercise 4 ❯  Exercise 5 ❯  Exercise 6 ❯


❮ 前章へ 次章へ ❯