CSSカラープロパティ
例
さまざまな要素のテキストの色を設定します。
body
{
color: red;
}
h1
{
color: #00ff00;
}
p.ex
{
color: rgb(0,0,255);
}
以下の「自分で試してみてください」の例をもっと見てください。
定義と使用法
color
プロパティは、テキストの色を指定します。
ヒント:テキストを読みやすくするために、背景色とテキストの色を組み合わせて使用します。
デフォルト値: | 指定されていない |
---|---|
遺伝性の: | はい |
アニメート可能: | はい。アニメート可能について読む |
バージョン: | CSS1 |
JavaScript構文: | オブジェクト.style.color = "#0000FF" |
ブラウザのサポート
表の数字は、プロパティを完全にサポートする最初のブラウザバージョンを示しています。
Property | |||||
---|---|---|---|---|---|
color | 1.0 | 3.0 | 1.0 | 1.0 | 3.5 |
CSS構文
color: color|initial|inherit;
プロパティ値
Value | Description | Play it |
---|---|---|
color | Specifies the text color. Look at CSS Color Values for a complete list of possible color values. | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
その他の例
例
テキストの色をHEX値で設定します。
body {color: #92a8d1;}
例
RGB値でテキストの色を設定します。
body {color: rgb(201, 76, 76);}
例
RGBA値でテキストの色を設定します。
body {color: rgba(201, 76, 76, 0.6);}
例
HSL値でテキストの色を設定します。
body {color: hsl(89, 43%, 51%);}
例
HSLA値でテキストの色を設定します。
body {color: hsla(89, 43%, 51%, 0.6);}
関連ページ
CSSチュートリアル:CSSテキスト
HTML DOMリファレンス:colorプロパティ