CSS Colors

CSS has several options for defining colors of both text and background areas on your pages.

These options can entirely replace the color attributes in plain HTML. In addition, you get new options that you just didn't have in plain HTML.

For example, in plain HTML, when you wanted to create an area with a specific color you were forced to include a table. With CSS, you can define an area to have a specific color without that area being part of a table.

CSS uses color values to specify a color. Typically, these are used to set a color either for the foreground of an element (i.e., its text) or else for the background of the element. They can also be used to affect the color of borders and other decorative effects.

The <color> CSS data type represents a color in the sRGB color space. A <color> may also include an alpha-channel transparency value, indicating how the color should composite with its background.

You can specify your color values in various formats. Following table lists all the possible formats

Hex Code#RRGGBBp{color:#00ff7f;}
Short Hex Code#RGBp{color:#6A7;}
RGB %rgb(rrr%,ggg%,bbb%)p{color:hsl(195, 100%, 50%);}
RGB Absolutergb(rrr,ggg,bbb)p{color:rgb(66, 214, 47);}
keywordaqua, black, etc.p{color:teal;}

RGBA Colors

This color value is specified using the rgb( ) property. This property takes three values, one each for red, green, and blue. The value can be an integer between 0 and 255 or a percentage.

RGBA color values are an extension of RGB color values with an alpha channel - which specifies the opacity for a color. An RGBA color value is specified with: rgba(red, green, blue, alpha). The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).

Example -

HSL Colors

As well as using Hexadecimal and RGB colors, CSS3 could also see the introduction of HSL (Hue, Saturation, Lightness) values.

HSL takes three values:

Hue is a degree on the color wheel; 0 (or 360) is red, 120 is green, 240 is blue. Numbers in between reflect different shades.Saturation is a percentage value; 100% is the full colour.Lightness is also a percentage; 0% is dark (black), 100% is light (white), and 50% is the average.This gives a very wide spectrum of available colors and tones.So far, HSL has been implemented in Opera 9.5, Safari 3, Konqueror and Mozilla browsers.

HSLA Colors

As RGBA is to RGB, HSLA is to HSL; that is, it allows a fourth value, which sets the Opacity (via the Alpha channel) of the element.

HSLA color values are an extension of HSL color values with an alpha channel - which specifies the opacity for a color.An HSLA color value is specified with: hsla(hue, saturation, lightness, alpha), where the alpha parameter defines the opacity. The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).


The opacity property in CSS specifies how transparent an element is.

Opacity has a default initial value of 1 (100% opaque). Opacity is not inherited, but because the parent has opacity that applies to everything within it. You cannot make a child element less transparent than the parent, without some trickery. Values are a number from 0 to 1 representing the opacity of the channel (the "alpha" channel). When an element has a value of 0 the element is completely invisible; a value of 1 is completely opaque (solid).

The CSS opacity property sets the opacity for the whole element (both background color and text will be opaque/transparent).The opacity property value must be a number between 0.0 (fully transparent) and 1.0 (fully opaque).

Color Name Hex Code
Decimal Code
Maroon 800000 12800
Red ff0000 25500
Orange ffA500 2551650
Yellow ffff00 2552550
Olive 808000 1281280
Green 008000 01280
Purple 800080 1280128
Fuchsia ff00ff 2550255
Lime 00ff00 02550
Teal 008080 0128128
Aqua 00ffff 0255255
Blue 0000ff 00255
Navy 000080 00128
Black 000000 000
Gray 808080 128128128
Silver c0c0c0 192192192
White ffffff 255255255

Css Color Chart - X11 Color Names

The colors in the following color chart represent the official X11 color names. Standardized by SVG 1.0, most of these colors are distributed with the X Windows System. These colors should be recognized by most modern browsers.

Color Name Hex Code
Decimal Code
IndianRed CD5C5C 2059292
LightCoral F08080 240128128
Salmon FA8072 250128114
DarkSalmon E9967A 233150122
LightSalmon FFA07A 255160122
Crimson DC143C 2202060
Red FF0000 25500
FireBrick B22222 1783434
DarkRed 8B0000 13900
Pink FFC0CB 255192203
LightPink FFB6C1 255182193
HotPink FF69B4 255105180
DeepPink FF1493 25520147
MediumVioletRed C71585 19921133
PaleVioletRed DB7093 219112147
LightSalmon FFA07A 255160122
Coral FF7F50 25512780
Tomato FF6347 2559971
OrangeRed FF4500 255690
DarkOrange FF8C00 2551400
Orange FFA500 2551650
Gold FFD700 2552150
Yellow FFFF00 2552550
LightYellow FFFFE0 255255224
LemonChiffon FFFACD 255250205
LightGoldenrodYellow FAFAD2 250250210
PapayaWhip FFEFD5 255239213
Moccasin FFE4B5 255228181
PeachPuff FFDAB9 255218185
PaleGoldenrod EEE8AA 238232170
Khaki F0E68C 240230140
DarkKhaki BDB76B 189183107
Lavender E6E6FA 230230250
Thistle D8BFD8 216191216
Plum DDA0DD 221160221
Violet EE82EE 238130238
Orchid DA70D6 218112214
Fuchsia FF00FF 2550255
Magenta FF00FF 2550255
MediumOrchid BA55D3 18685211
MediumPurple 9370DB 147112219
Amethyst 9966CC 153102204
BlueViolet 8A2BE2 13843226
DarkViolet 9400D3 1480211
DarkOrchid 9932CC 15350204
DarkMagenta 8B008B 1390139
Purple 800080 1280128
Indigo 4B0082 750130
SlateBlue 6A5ACD 10690205
DarkSlateBlue 483D8B 7261139
MediumSlateBlue 7B68EE 123104238
GreenYellow ADFF2F 17325547
Chartreuse 7FFF00 1272550
LawnGreen 7CFC00 1242520
Lime 00FF00 02550
LimeGreen 32CD32 5020550
PaleGreen 98FB98 152251152
LightGreen 90EE90 144238144
MediumSpringGreen 00FA9A 0250154
SpringGreen 00FF7F 0255127
MediumSeaGreen 3CB371 60179113
SeaGreen 2E8B57 4613987
ForestGreen 228B22 3413934
Green 008000 01280
DarkGreen 006400 01000
YellowGreen 9ACD32 15420550
OliveDrab 6B8E23 10714235
Olive 808000 1281280
DarkOliveGreen 556B2F 8510747
MediumAquamarine 66CDAA 102205170
DarkSeaGreen 8FBC8F 143188143
LightSeaGreen 20B2AA 32178170
DarkCyan 008B8B 0139139
Teal 008080 0128128
Aqua 00FFFF 0255255
Cyan 00FFFF 0255255
LightCyan E0FFFF 224255255
PaleTurquoise AFEEEE 175238238
Aquamarine 7FFFD4 127255212
Turquoise 40E0D0 64224208
MediumTurquoise 48D1CC 72209204
DarkTurquoise 00CED1 0206209
CadetBlue 5F9EA0 95158160
SteelBlue 4682B4 70130180
LightSteelBlue B0C4DE 176196222
PowderBlue B0E0E6 176224230
LightBlue ADD8E6 173216230
SkyBlue 87CEEB 135206235
LightSkyBlue 87CEFA 135206250
DeepSkyBlue 00BFFF 0191255
DodgerBlue 1E90FF 30144255
CornflowerBlue 6495ED 100149237
MediumSlateBlue 7B68EE 123104238
RoyalBlue 4169E1 65105225
Blue 0000FF 00255
MediumBlue 0000CD 00205
DarkBlue 00008B 00139
Navy 000080 00128
MidnightBlue 191970 2525112
Cornsilk FFF8DC 255248220
BlanchedAlmond FFEBCD 255235205
Bisque FFE4C4 255228196
NavajoWhite FFDEAD 255222173
Wheat F5DEB3 245222179
BurlyWood DEB887 222184135
Tan D2B48C 210180140
RosyBrown BC8F8F 188143143
SandyBrown F4A460 24416496
Goldenrod DAA520 21816532
DarkGoldenrod B8860B 18413411
Peru CD853F 20513363
Chocolate D2691E 21010530
SaddleBrown 8B4513 1396919
Sienna A0522D 1608245
Brown A52A2A 1654242
Maroon 800000 12800
White FFFFFF 255255255
Snow FFFAFA 255250250
Honeydew F0FFF0 240255240
MintCream F5FFFA 245255250
Azure F0FFFF 240255255
AliceBlue F0F8FF 240248255
GhostWhite F8F8FF 248248255
WhiteSmoke F5F5F5 245245245
Seashell FFF5EE 255245238
Beige F5F5DC 245245220
OldLace FDF5E6 253245230
FloralWhite FFFAF0 255250240
Ivory FFFFF0 255255240
AntiqueWhite FAEBD7 250235215
Linen FAF0E6 250240230
LavenderBlush FFF0F5 255240245
MistyRose FFE4E1 255228225
Gainsboro DCDCDC 220220220
LightGrey D3D3D3 211211211
Silver C0C0C0 192192192
DarkGray A9A9A9 169169169
Gray 808080 128128128
DimGray 696969 105105105
LightSlateGray 778899 119136153
SlateGray 708090 112128144
DarkSlateGray 2F4F4F 477979
Black 000000 000