There are five kinds of values that specify color in CSS — color
keywords, system color keywords, hexadecimal color notation, decimal functional
rgb notation, and percentage functional rgb notation.
Color Keywords
There are 17 Color Keywords, also called named colors, defined in CSS2.1:
aqua
- rgb(0,255,255)
black
- rgb(0,0,0)
blue
- rgb(0,0,255)
fuchsia
- rgb(255,0,255)
gray
- rgb(128,128,128)
green
- rgb(0,128,0)
lime
- rgb(0,255,0)
maroon
- rgb(128,0,0)
navy
- rgb(0,0,128)
olive
- rgb(128,128,0)
orange
- rgb(255,80,0)
purple
- rgb(128,0,128)
red
- rgb(255,0,0)
silver
- rgb(192,192,192)
teal
- rgb(0,128,128)
white
- rgb(255,255,255)
yellow
- rgb(255,255,0)
Example 1: <p style="font-size:35px;font-family:'Times New
Roman';color:aqua">the quick brown fox jumps over the lazy dog</p>
There are 148 color keywords defined in CSS 3. However, there are only 139
individual colors. This is because there are a pair of color keywords for each of
the gray colors — one spelt "gray" and the other spelt "grey". Also,
fuchsia
and magenta
is the same color, and so is aqua
and cyan
.
Internet Explorer 6 and 7 ignore the following color keywords:
lightgray
, darkgrey
, grey
, dimgrey
,
lightslategrey
, slategrey
, darkslategrey
.
Therefore, the keywords lightgrey
, darkgray
,
gray
, ddimgray
,
lightslategray
,
slategray
, darkslategray
can be used instead because they refer to the same colors
Here is a table of the CSS 3 colors,
source(http://en.wikipedia.org/wiki/Web_colors#X11_color_names):
Color Keyword |
Hex code
R G B |
Decimal code
R G B |
Red colors |
indianred |
CD 5C 5C |
205 92 92 |
lightcoral |
F0 80 80 |
240 128 128 |
salmon |
FA 80 72 |
250 128 114 |
darksalmon |
E9 96 7A |
233 150 122 |
lightsalmon |
FF A0 7A |
255 160 122 |
crimson |
DC 14 3C |
220 20 60 |
red |
FF 00 00 |
255 0 0 |
firebrick |
B2 22 22 |
178 34 34 |
darkred |
8B 00 00 |
139 0 0 |
Pink colors |
pink |
FF C0 CB |
255 192 203 |
lightpink |
FF B6 C1 |
255 182 193 |
hotpink |
FF 69 B4 |
255 105 180 |
deeppink |
FF 14 93 |
255 20 147 |
mediumvioletred |
C7 15 85 |
199 21 133 |
palevioletred |
DB 70 93 |
219 112 147 |
Orange colors |
coral |
FF 7F 50 |
255 127 80 |
tomato |
FF 63 47 |
255 99 71 |
orangered |
FF 45 00 |
255 69 0 |
darkorange |
FF 8C 00 |
255 140 0 |
orange |
FF A5 00 |
255 165 0 |
Yellow colors |
gold |
FF D7 00 |
255 215 0 |
yellow |
FF FF 00 |
255 255 0 |
lightyellow |
FF FF E0 |
255 255 224 |
lemonchiffon |
FF FA CD |
255 250 205 |
lightgoldenrodyellow |
FA FA D2 |
250 250 210 |
papayawhip |
FF EF D5 |
255 239 213 |
moccasin |
FF E4 B5 |
255 228 181 |
peachpuff |
FF DA B9 |
255 218 185 |
palegoldenrod |
EE E8 AA |
238 232 170 |
khaki |
F0 E6 8C |
240 230 140 |
darkkhaki |
BD B7 6B |
189 183 107 |
Purple colors |
lavender |
E6 E6 FA |
230 230 250 |
thistle |
D8 BF D8 |
216 191 216 |
plum |
DD A0 DD |
221 160 221 |
violet |
EE 82 EE |
238 130 238 |
orchid |
DA 70 D6 |
218 112 214 |
fuchsia |
FF 00 FF |
255 0 255 |
magenta |
FF 00 FF |
255 0 255 |
mediumorchid |
BA 55 D3 |
186 85 211 |
mediumpurple |
93 70 DB |
147 112 219 |
blueviolet |
8A 2B E2 |
138 43 226 |
darkviolet |
94 00 D3 |
148 0 211 |
darkorchid |
99 32 CC |
153 50 204 |
darkmagenta |
8B 00 8B |
139 0 139 |
purple |
80 00 80 |
128 0 128 |
indigo |
4B 00 82 |
75 0 130 |
slateblue |
6A 5A CD |
106 90 205 |
darkslateblue |
48 3D 8B |
72 61 139 |
mediumslateblue |
7B 68 EE |
123 104 238 |
|
Color Keyword |
Hex code
R G B |
Decimal code
R G B |
Green colors |
greenyellow |
AD FF 2F |
173 255 47 |
chartreuse |
7F FF 00 |
127 255 0 |
lawngreen |
7C FC 00 |
124 252 0 |
lime |
00 FF 00 |
0 255 0 |
limegreen |
32 CD 32 |
50 205 50 |
palegreen |
98 FB 98 |
152 251 152 |
lightgreen |
90 EE 90 |
144 238 144 |
mediumspringgreen |
00 FA 9A |
0 250 154 |
springgreen |
00 FF 7F |
0 255 127 |
mediumseagreen |
3C B3 71 |
60 179 113 |
seagreen |
2E 8B 57 |
46 139 87 |
forestgreen |
22 8B 22 |
34 139 34 |
green |
00 80 00 |
0 128 0 |
darkgreen |
00 64 00 |
0 100 0 |
yellowgreen |
9A CD 32 |
154 205 50 |
olivedrab |
6B 8E 23 |
107 142 35 |
olive |
80 80 00 |
128 128 0 |
darkolivegreen |
55 6B 2F |
85 107 47 |
mediumaquamarine |
66 CD AA |
102 205 170 |
darkseagreen |
8F BC 8F |
143 188 143 |
lightseagreen |
20 B2 AA |
32 178 170 |
darkcyan |
00 8B 8B |
0 139 139 |
teal |
00 80 80 |
0 128 128 |
Blue/Cyan colors |
aqua |
00 FF FF |
0 255 255 |
cyan |
00 FF FF |
0 255 255 |
lightcyan |
E0 FF FF |
224 255 255 |
paleturquoise |
AF EE EE |
175 238 238 |
aquamarine |
7F FF D4 |
127 255 212 |
turquoise |
40 E0 D0 |
64 224 208 |
mediumturquoise |
48 D1 CC |
72 209 204 |
darkturquoise |
00 CE D1 |
0 206 209 |
cadetblue |
5F 9E A0 |
95 158 160 |
steelblue |
46 82 B4 |
70 130 180 |
lightsteelblue |
B0 C4 DE |
176 196 222 |
powderblue |
B0 E0 E6 |
176 224 230 |
lightblue |
AD D8 E6 |
173 216 230 |
skyblue |
87 CE EB |
135 206 235 |
lightskyblue |
87 CE FA |
135 206 250 |
deepskyblue |
00 BF FF |
0 191 255 |
dodgerblue |
1E 90 FF |
30 144 255 |
cornflowerblue |
64 95 ED |
100 149 237 |
royalblue |
41 69 E1 |
65 105 225 |
blue |
00 00 FF |
0 0 255 |
mediumblue |
00 00 CD |
0 0 205 |
darkblue |
00 00 8B |
0 0 139 |
navy |
00 00 80 |
0 0 128 |
midnightblue |
19 19 70 |
25 25 112 |
|
Color Keyword |
Hex code
R G B |
Decimal code
R G B |
Brown colors |
cornsilk |
FF F8 DC |
255 248 220 |
blanchedalmond |
FF EB CD |
255 235 205 |
bisque |
FF E4 C4 |
255 228 196 |
navajowhite |
FF DE AD |
255 222 173 |
wheat |
F5 DE B3 |
245 222 179 |
burlywood |
DE B8 87 |
222 184 135 |
tan |
D2 B4 8C |
210 180 140 |
rosybrown |
BC 8F 8F |
188 143 143 |
sandybrown |
F4 A4 60 |
244 164 96 |
goldenrod |
DA A5 20 |
218 165 32 |
darkgoldenrod |
B8 86 0B |
184 134 11 |
peru |
CD 85 3F |
205 133 63 |
chocolate |
D2 69 1E |
210 105 30 |
saddlebrown |
8B 45 13 |
139 69 19 |
sienna |
A0 52 2D |
160 82 45 |
brown |
A5 2A 2A |
165 42 42 |
maroon |
80 00 00 |
128 0 0 |
White colors |
white |
FF FF FF |
255 255 255 |
snow |
FF FA FA |
255 250 250 |
honeydew |
F0 FF F0 |
240 255 240 |
mintcream |
F5 FF FA |
245 255 250 |
azure |
F0 FF FF |
240 255 255 |
aliceblue |
F0 F8 FF |
240 248 255 |
ghostwhite |
F8 F8 FF |
248 248 255 |
whitesmoke |
F5 F5 F5 |
245 245 245 |
seashell |
FF F5 EE |
255 245 238 |
beige |
F5 F5 DC |
245 245 220 |
oldlace |
FD F5 E6 |
253 245 230 |
floralwhite |
FF FA F0 |
255 250 240 |
ivory |
FF FF F0 |
255 255 240 |
antiquewhite |
FA EB D7 |
250 235 215 |
linen |
FA F0 E6 |
250 240 230 |
lavenderblush |
FF F0 F5 |
255 240 245 |
mistyrose |
FF E4 E1 |
255 228 225 |
Grey colors |
gainsboro |
DC DC DC |
220 220 220 |
lightgrey |
D3 D3 D3 |
211 211 211 |
silver |
C0 C0 C0 |
192 192 192 |
darkgray |
A9 A9 A9 |
169 169 169 |
gray |
80 80 80 |
128 128 128 |
dimgray |
69 69 69 |
105 105 105 |
lightslategray |
77 88 99 |
119 136 153 |
SlateGray |
70 80 90 |
112 128 144 |
darkslategray |
2F 4F 4F |
47 79 79 |
black |
00 00 00 |
0 0 0 |
|
Example 2: <p style="font-size:35px;font-family:'Times New
Roman';color:crimson">the quick brown fox jumps over the lazy dog</p>
System Color Keywords
The system color keywords refer to the colors used by the
operating system in its GUI. These keywords make it
possible to create a web page with an interface that mimics the viewer's
operating system GUI. CSS 2.1 specifies the following system color
keywords (source:
http://www.w3.org/TR/CSS2/ui.html#system-colors).
ActiveBorder
- Active window border.
ActiveCaption
- Active window caption background color.
AppWorkspace
- Background color of multiple document interface.
Background
- Desktop background color.
ButtonFace
- Face color for three-dimensional display elements.
ButtonHighlight
- Highlight color for three-dimensional display elements (for
edges facing away from the light source).
ButtonShadow
- Shadow color for three-dimensional display elements.
ButtonText
- Text on push buttons.
CaptionText
- Text in caption, size box, and scrollbar arrow box.
GrayText
- Grayed (disabled) text. This color is set to #000 if
the current display driver does not support a solid gray color.
Highlight
- Item(s) selected in a control background color.
HighlightText
- Text of item(s) selected in a control.
InactiveBorder
- Inactive window border.
InactiveCaption
- Inactive window caption background color.
InactiveCaptionText
- Color of text in an inactive caption.
InfoBackground
- Background color for tooltip controls.
InfoText
- Text color for tooltip controls.
Menu
- Menu background color.
MenuText
- Text in menus.
Scrollbar
- Scroll bar gray area.
ThreeDDarkShadow
- Dark shadow for three-dimensional display elements.
ThreeDFace
- Face color for three-dimensional display elements.
ThreeDHighlight
- Highlight color for three-dimensional display elements.
ThreeDLightShadow
- Light color for three-dimensional display elements
(for edges facing the light source).
ThreeDShadow
- Dark shadow for three-dimensional display elements.
Window
- Window background color.
WindowFrame
- Window frame.
WindowText
- Text in windows.
Example 3: <p style="font-size:35px;font-family:'Times New
Roman';color:WindowText">the quick brown fox jumps over the lazy dog</p>
Hexadecimal Notation
A hexadecimal notation color value consists of the pound sign (#) followed by six or three hexadecimal digits - example: #344da4
. The first two digits (from the left) represent red
, the next two digits represent green
and the last two represent blue
.
Since each two digit pair is in hexadecimal, the maximum value is ff
or 255
in decimal. Thus, each of the three primary colors - red, green, blue are represented by 256 different levels.
For example, #344da4
represents a red
level of 34 hexadecimal or 52 decimal, a green
level of 4d hexadecimal or 77 decimal and a blue
level of a4 hexadecimal or 164 decimal. A level of 255 represents the strongest level of a particular color and a level of 0 represents the weakest level - complete absence of the color.
Numbers can be converted from hexadecimal to decimal and vice versa using a calculator.
Example 4: <p style="font-size:35px;font-family:'Times New
Roman';color:#FF7F50">coral the quick brown fox jumps over the lazy dog</p>
In the above example the color in decimal rgb notation is
rgb(255,127,80)
.
A hexadecimal notation value can be shortened if the value of each primary
color consists of a repeated number or letter.
Example 5: <p style="font-size:35px;font-family:'Times New
Roman';color:#AD9"> the quick brown fox jumps over the lazy dog</p>
In the above example, the color value can be expanded to #AADD99
which
is equivalent to rgb(170,221,153)
.
Functional RGB Notation
The Functional RGB Notation consists of a decimal number triplet of either percentages or integers. The triplet represents the three primary colors red
, green
and blue
.
Decimal Functional RGB Notation
In this notation the rgb triplet is specified as three comma separated decimal numbers enclosed in parentheses. The range of values is 0 to 255. Here is an example of the functional rgb notation using a decimal number triplet: rgb(156,45,56)
. In this example the level of red
is 156, green
is 45 and blue
is 56.
Example 6: <p style="font-size:35px;font-family:'Times New
Roman';color:rgb(255,105,180)">the quick brown fox jumps over the lazy dog</p>
Percentage Functional RGB Notation
In this notation the rgb triplet is specified as three comma separated decimal percentages enclosed in parentheses. The range of values is 0% to 100%, decimal values (example 10.5%) are allowed. Any percentage greater than 100% is considered equal to 100%. Example: (350% is considered 100%). The color in the previous decimal functional rgb notation can be converted to percentage function rgb notation using the formula:
(primary color value ÷ 255) × 100
Only one decimal place is necessary since the rounded-off computed value can
represent all the numbers from 0 to 255.
Example 7: <p style="font-size:35px;font-family:'Times New
Roman';color:rgb(100%,49.8%,31.3%)">coral the quick brown fox jumps over the
lazy dog</p>
In the above example, the color value can also be expressed as rgb(255,
127,80)