HTML:カラーコードの定義-仕組み
HTMLではさまざまな方法で色を定義できます。 これを行う方法を示します。
HTMLでカラーコードを定義する
基本的に、HTMLでは2つの方法で色を定義できます-色の名前または16進コードのいずれかです。 色の名前は覚えやすいですが、ほとんどのWeb開発者は16進コードを使用して色をコーディングします。
- 16進コード:16進数には、色分けのために常に6桁があります。 最初の2桁は赤のコンポーネント、次の2桁は緑、最後の2桁は青のコンポーネントを表しています。 色の前には常に「#」の菱形記号があります。 したがって、次のように赤い背景色を定義できます: ""。 スペルがスタイルシートなしで古くなっていることに注意してください。 たとえば、次のコードは避けてください: ""。
- 色名:基本的には16進コードと同じように機能します。 次のような赤い背景を作成できます: ""。 インターネットでは、何百もの色の名前を持つ詳細なテーブルを見つけることができます。
色の定義を外部スタイルシート(CSS)に移動する方が専門的です。 もう1つの実用的なヒントでは、HTMLとCSSの違いについて説明します。