CSS color and background tutorial

The educational technology and digital learning wiki
(Redirected from CSS color tutorial)
Jump to navigation Jump to search
Learning goals
  • Understand CSS 2 and CSS color models
  • Be able to user background and font colors
Concurrent
Moving on
Level and target population
  • Beginners
Teaching materials
Remarks
  • This tutorial is intended for students in educational technology or any other field that is technology intensive. For people who need less, there exist many easy CSS tutorials on the web. This text is intended for students who also must learn principles and who are willing to learn CSS by doing a project, looking at CSS code and online reference manuals.
  • Ideally, a teacher also should assign a text formatting task, during or before assigning this tutorial for reading).

Introduction

CSS 2 colors

In CSS 2.1 (support by nearly all browsers on the market, i.e. also back two older generations), there exist several properties for which a color can be set.

Let's have a look at some example code that demonstrates two of the most popular color properties and the typical RGB hex notation for color values:

The following inline CSS code

  <p> <span style="background-color: #0000ff; color: #ffffff;"> 
      Blue background and white foreground</span> demo </p>

would show like this:

Blue background and white foreground demo

We shall explain more details below, but before we shall present an overview of CSS 2 color properties and then introduce the RGB color model used in CSS 2.

CSS 2 color related properties

(1) Setting the font color

  • color
defines the foreground color for text content
Example: color: #ff0000;

(2) Setting the background “Authors may specify the background of an element (i.e., its rendering surface) as either a color or an image. In terms of the box model, "background" refers to the background of the content, padding and border areas. Border colors and styles are set with the border properties. Margins are always transparent.” (CSS 2 spec.)

  • background-color
defines the background’s color of an element
Example: background-color: red;
  • background-image
sets the background image for an element. An image is not really a color, but can be used for the same purpose
Example: background-image: url ("flower.png");
  • background-repeat
defines the tiling (and tiling direction) of a background-image
  • background-position
defines the position of a background image
  • background-attachment
defines whether the background image scrolls with the containing block or stays fixed with respect to the viewport (i.e. what is displayed)
  • background
is a short hand notation that allows to define all background definitions
Example:background: url("flower.png") gray 50% repeat fixed

The RGB color model

A representation of additive color mixing (Wikipedia)

RGB colors are the most popular ones used in computing applications. A color is defined by the amount of Red - Green - Blue.

RGB is the way computer monitors work. E.g. to get a nice yellow you need 100% Red + 100% Green + 0% Blue. RGB is a so-called additive color mixing model. “Projection of primary color lights on a screen shows secondary colors where two overlap; the combination of all three of red, green, and blue in appropriate intensities makes white.” (Wikipedia). Now if you project each of these primary colors with different intensity, overlapping colors will change.

This model is not how colors work when you mix real paint. Then you'd rather work with a red-yellow-blue model. Color printers yet work with another model, i.e. magenta, cyan and yellow (or more).

RGB colors can be encoded in various ways. For Internet formats such as HTML, CSS or Flash, most often a hex triplet is used, i.e. a hexadecimal 6 digit number. With 2 hexadecimal digits you can represent numbers in the range of 0 to 255, i.e. only a reduced set of colors.

CSS 2 color values

There are two way of defining CSS 2 colors. Either by their name (but this only works for 17 colors) or by a so-called RGB value. The latter can be specified in four different ways as we shall show in the example below. The 17 pre-defined color names in CSS 2.1 are the following, according to the CSS 2.1 specification from which we made a screen shot:

The 17 official CSS 2 color definitions

Otherwise, you may choose from several RGB numerical colors specifications as the following example shows. The following example will set the color of a text:

em { color: #f00 }              /* #rgb = Red-Green-Blue shortcut for rrggbb*/
em { color: #ff0000 }           /* #rrggbb */
em { color: rgb(255,0,0) }      
em { color: rgb(100%, 0%, 0%) }

In order to set the background-color use something like:

em { background-color: #f00 }              /* #rgb = Red-Green-Blue shortcut for rrggbb*/
em { background-color: #ff0000 }           /* #rrggbb */
em { background-color: rgb(255,0,0) }      
em { background-color: rgb(100%, 0%, 0%) }

CSS 3 colors

CSS 3 implements (of course) all CSS 2 features. In addition it implements a whole range of new color related properties and values.

RGB colors

Work like in CSS. The only difference is that there are more color names you could use. The following table was taken as is from Wikipedia:

X11/CSS 3 color names table (copied "as is" from Wikipedia):
HTML name Hex code
R G B
Decimal code
R G B
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
PaleVioletRed DB 70 93 219 112 147
MediumVioletRed C7 15 85 199  21 133
Red colors
LightSalmon FF A0 7A 255 160 122
Salmon FA 80 72 250 128 114
DarkSalmon E9 96 7A 233 150 122
LightCoral F0 80 80 240 128 128
IndianRed CD 5C 5C 205  92  92
Crimson DC 14 3C 220  20  60
FireBrick B2 22 22 178  34  34
DarkRed 8B 00 00 139   0   0
Red FF 00 00 255   0   0
Orange colors
OrangeRed FF 45 00 255  69   0
Tomato FF 63 47 255  99  71
Coral FF 7F 50 255 127  80
DarkOrange FF 8C 00 255 140   0
Orange FF A5 00 255 165   0
Yellow colors
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
Gold FF D7 00 255 215   0
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
HTML name Hex code
R G B
Decimal code
R G B
Green colors
DarkOliveGreen 55 6B 2F  85 107  47
Olive 80 80 00 128 128   0
OliveDrab 6B 8E 23 107 142  35
YellowGreen 9A CD 32 154 205  50
LimeGreen 32 CD 32  50 205  50
Lime 00 FF 00   0 255   0
LawnGreen 7C FC 00 124 252   0
Chartreuse 7F FF 00 127 255   0
GreenYellow AD FF 2F 173 255  47
SpringGreen 00 FF 7F   0 255 127
MediumSpringGreen 00 FA 9A   0 250 154
LightGreen 90 EE 90 144 238 144
PaleGreen 98 FB 98 152 251 152
DarkSeaGreen 8F BC 8F 143 188 143
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
Cyan colors
MediumAquamarine 66 CD AA 102 205 170
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
LightSeaGreen 20 B2 AA  32 178 170
CadetBlue 5F 9E A0  95 158 160
DarkCyan 00 8B 8B   0 139 139
Teal 00 80 80   0 128 128
Blue colors
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
SteelBlue 46 82 B4  70 130 180
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
HTML name Hex code
R G B
Decimal code
R G B
Purple/Violet/Magenta 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
DarkSlateBlue 48 3D 8B  72  61 139
RebeccaPurple 66 33 99 102  51 153
SlateBlue 6A 5A CD 106  90 205
MediumSlateBlue 7B 68 EE 123 104 238
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
Gray/Black 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

Links to official documents

The HSL/HSI model

The HSL (Hue-saturation-lightness) model, also known as HSI (hue-saturation-intensity) defines colors with a different model.

  1. Hue, the color: Represented as a position in the 360 degrees of a color circle.
  2. Saturation, the intensity or "purity" of the color: Ranges from 0-100%. 0 means no color, 100% means full color.
  3. Lightness or Intensity. You could think of 100% as "full white", and of 0% as "no white or full black". 50% is normal (no white, no black).

The Hue scale from 0 to 360 degrees is the following:

The hue scale (Wikipedia)

The following picture shows the same color space as a circle

HSL color space. Source: Wikimedia commons

Sometimes the HSL is represented as wheel with a triangle inside, but often you will find either a cylinder or circles that represent cross sections of the cylinder since you can't represent all colors in a single flat picture.

Wikipedia's article on HSL and HSV includes a HSL-HSV comparison picture from which we extracted the HSL part:

HSL Above (a): cut-away 3D models of HSL. To the right two-dimensional plots showing two of the model’s three parameters at once, holding the other constant: cylindrical shell (b) of constant saturation, in this case the outside edge of each cylinder; horizontal cross-section (c) of constant HSL lightness value, in this case the slices halfway down each cylinder; and rectangular vertical cross-section (d) of constant hue, in this case of hues 0° red and its complement 180° cyan.

Notice: HSV is a similar model, but it's a bit more difficult to grasp. Below we just show a figure that compares HSL with HSV.

Comparison of the HSL (left) and HSV (right) color models. Source: Wikipedia, retrieved 17:38, 11 September 2009 (UTC)

According to the CSS specification, retrieved 17:38, 11 September 2009 (UTC)

CSS3 adds numerical hue-saturation-lightness (HSL) colors as a complement to numerical RGB colors. It has been observed that RGB colors have the following limitations:

  • RGB is hardware-oriented: it reflects the use of CRTs.
  • RGB is non-intuitive. People can learn how to use RGB, but actually by internalizing how to translate hue, saturation and lightness, or something similar, to RGB.
Advantages of HSL are that it is symmetrical to lightness and darkness (which is not the case with HSV for example), and it is trivial to convert HSL to RGB.

CSS 3 and SVG implement the HSL model. Color (hue) is defined by the position in the color wheel, e.g. red = 0, red = 360, blue=240. Saturation and lightness are represented by percentages from 0 to 100%. Important: "normal" lightness is 50%.

Below is table of the main colors (at 30i intervals). We present three situations:

  • Saturation is set to 100% and lightness to 50% (normal)
  • Saturation of 50% and lightness of 25% (dark)
  • Saturation of 75% and lightness of 75% (pastel)

Warning: You need a somewhat CSS 3 capable browser like Firefox 3+ or IE 9 ( IE 8 will not work)

Hue Color name Sat=100% / Light=50% Sat=50% / Light=25% Sat=75% / light=75%
0 red 0 - red 0 - red 0 - red
30 orange 30 - orange 30 - orange 30 - orange
60 yellow 60 - yellow 60 - yellow 60 - yellow
90 yellow-green 90 - yellow-green 90 - yellow-green 90 - yellow-green
120 green 120 - green 120 - green 120 - green
150 green-cyan 150 - green-cyan 150 - green-cyan 150 - green-cyan
180 cyan 180 - cyan 180 - cyan 180 - cyan
210 cyan-blue 210 - cyan-blue 210 - cyan-blue 210 - cyan-blue
240 blue 240 - blue 240 - blue 240 - blue
270 blue-magenta 270 - blue-magenta 270 - blue-magenta 270 - blue-magenta
300 magenta 300 - magenta 300 - magenta 300 - magenta
330 magenta-red 330 - magenta-red 330 - magenta-red 330 - magenta-red
360 red 360 - red 360 - red 360 - red

Now, where is white an black ?

  • Any hue that is 100% saturated and 100% lightness is white
  • Any hue that is 0% saturated and/or lightness is black

So basically, an HSL color goes

  • From colorful to colorless in terms of saturation
  • From black to normal to white in terms of lightness (50% is normal)

Below is screen capture from the CSS Color Module Level 3 (Working draft, retrieved 17:38, 11 September 2009 (UTC)) that shows on the X axis the saturation (100%, 75%, 50%, 25%, 0%) and on the Y axis the lightness.

HSL Example - 0i red (Source: W3C)

Finally, here are some CSS code examples:

 { color: hsl(0, 100%, 50%) }   /* red */
 { color: hsl(120, 100%, 50%) } /* green */ 
 { color: hsl(120, 100%, 25%) } /* dark green */ 
 { color: hsl(120, 100%, 75%) } /* light green */ 
 { color: hsl(120, 75%, 75%) }  /* pastel green, and so on */

E.g. The following HSL CSS code

  <p style="color: hsl(240,75%,75%);"> Kind of not so blue</p>

would show like this (your browser may not support this):

Kind of not so blue

For more information about HSL (and HSV), we point again to Wikipedia's HSL and HSV article.

HSL colors with CSS3

In CSS, the hsl value is defined by the position in the color wheel, e.g. red = 0, red = 360, blue=240. Saturation and lightness are represented by percentages. Here are a few examples:

 { color: hsl(0, 100%, 50%) }   /* red */
 { color: hsl(120, 100%, 75%) } /* light green */ 
 { color: hsl(120, 75%, 75%) }  /* pastel green, and so on */

E.g. The following HSL CSS code

  <p style="color: hsl(240,75%,75%);"> Kind of not so blue</p>

would show like this (your browser may not support this):

Kind of not so blue

Alpha channel

In computer graphics, alpha compositing is the process of combining an image with a background to create the appearance of partial transparency (Wikipedia)

In more simple terms, you can set the alpha to some percentage:

  • 100% can't see through
  • 80% bad see trough
  • 50% in between
  • 30% good see through
  • 10% good see through, but very little color
  • 0% no color left
Alpha color channel

Hint: With the alpha channel you can create other effects than see-through "windows". E.g. you can overlay textures with color or the other way round.

In CSS3 (if your browser supports it), you also can define the alpha channel. You may use so-called RGBA values using the rgba () notation for RGB values. a in rgba stands for alpha. Some examples:

  p { background-color: rgba(0,0,255,0.5) }        /* semi-transparent solid blue */

The following RGBA CSS inline code

  <p style="float:right; background-color: rgba(0,0,255,0.3);"> Kind of blue</p>

would show like the "Kind of blue" box to the right (your browser may not support this):

Kind of blue

Alternatively you can use the opacity property that does the same, e.g.

 
 background: rgb(255, 0, 0) ; opacity: 0.2;">

Finally, in CSS 3, you also may use HSL with an alpha channel, i.e. define an hsla value:

/* HSL model with alpha channel */
p { color: hsla(120, 100%, 50%, 1) }  /* green */
p { color: hsla(120, 100%, 50%, 0.5) } /* semi-transparent green */
p { color: hsla(120, 100%, 50%, 0.1) } /* very transparent green */

CSS 2 Background properties

When you use a background image within an element it is by default tiled vertically and horizentally, under the condition that its x/y dimensions are smaller than the styled element.

The background-repeat property allows to change default settings. E.g. to inhibit repetition, use:

background-image: url(flower.png);
background-repeat: no-repeat;

html vs. body vs. universal background

Example file:

Using background images is more difficult than it may seem. In particular there are a few principles and issues that you should be aware of:

  • Pictures will shine through all elements, unless these elements explicitly define a background. In other words, if an element is transparent (this is the default), the picture underneath will show through empty spaces in the "box", i.e. the rectangle define by the element's boundaries.
  • Watch out for interactions between using the universal rule, the body and the html for setting a background. E.g. if you define a background picture in the universal rule, bits can shine through in various HTML elements, even if you defined a other background in the body element. This, because backgrounds are not inherited.
  • Various other properties also may have effects that may need some tuning. E.g. an none repeated background will display the picture as a whole.

If you set a background image like this, i.e. as default for all elements:

 
    * {
      background-image: url(tournesol.png);
      }

the pictures will fill the whole web browser window in the background. Images will not repeat again at each element level.

If you set a background image as "html" background like this:

 
 html {
       background-image: url(tournesol.png);
       }

then the whole visible window area will be filled with the picture.

If you set a background image as "body" background like this:

 
 body {
       background-image: url(tournesol.png);
       }

and if neither body nor the "*" has a background image it will fill the whole window as above.

However, if there is a background imageor color for the html tag or the universal selector, then only the the space taken up by the body will be filled. In particular, margins will not be filled and space left from the end of your content down to the end of the browser window will not be filled with this image.

Background image repetition

  • Repeat in the x direction
 
 background-repeat: repeat-x;

Positioning background images

Background pictures can be positioned with respect to the boundaries of the element.

E.g. if you insert a picture in the body you could put it at bottom right like this:

 
background-image: url(flower.png);
background-repeat: no-repeat;
background-position: bottom right;

background-position takes two values that represent both the y and the x offset, i.e. how much it will go down and to the right. If only one value is specified it refers to the horizontal x position.

Examples:

 
 background-position: 75px 150px;
 background-position: 60% 20px;

In order to center a picture, you could use:

 
background-image: url(flower.png);
background-repeat: no-repeat;
background-position: bottom right;

Fixing background images

You also can fix a background image with respect to the so-called viewport (what the users sees in the browser window), so that it stays when a user will scroll. More precisely: “If a background image is specified, this property specifies whether it is fixed with regard to the viewport ('fixed') or scrolls along with the containing block ('scroll').” (CSS 2 spec).

Example:

 
background-image: url(flower.png);
background-repeat: no-repeat;
background-attachment: fixed;

The background-attachment property will take the following values:

  • scrolll (this is the default)
  • fixed: Will scroll up-down/left-right when the user (or a script) uses scrolling.
  • inherit

Note: An image is only visible if it sits in the content, padding or border area of the element.

The background shorthand

The CSS3 syntax is the following (see some examples later):

background: background-color-value background-image-value background-repeat-value background-attachment-value background-position-value

Property values have to be presented in this order, but you can omit any you like:

Simple background examples:

 
 body {
  background:#ffffff url('flower.png') no-repeat right top;
  }
 body {
  background:#url('flower.png') no-repeat 50% top;
 }

CSS3 background properties

This is not complete, we only show some properties of the CSS Backgrounds and Borders Module Level 3 (draft standard, 15 feb 2011).

Multiple images

In CSS3 (only), one also can define multiple background images in two different ways. For now, just a simple example:

 
p {
background: 
url(one.jpg) top center no-repeat,
url(two.png) 40% 20px no-repeat,
url(three.png) 60% 20px no-repeat,
url(four.png) 3em 3em repeat-x,
url(car.gif) center no-repeat;
}

Notice how these background image definitions are separated by commas !

CSS 3 background size and background origin

The CSS3 (only!) property background-size allows specify the size of background images using length, percentages, or contain, cover or auto.

This property is defined in the CSS Backgrounds and Borders Module Level 3 W3C Candidate Recommendation 15 February 2011. As of nov 2001 this should be implement in most recent browsers.

The most interesting value is cover since it allows to deal with "fluid" designs, i.e. web pages that adapt to the size of the screen.

Examples:

background-size: 300px;       /* 300 px wide and height is auto*/
background-size: 300px 200px; /* 300px width and 200px height */
background-size: 50% 50%;     /* set size = 50% of the parent element */
background-size: auto;
background-size: contain;     /* largest image size that makes it fit inside */
background-size: cover;       /* smallest image size that makes it fit inside */

If it doesn't work in your (older) browser, you could try:

 -moz-background-size: 
 -o-background-size: 
 -webkit-background-size:

In addition, you may have to use the background-origin property that specifies the background positioning area. The example lines should be self-explaining.

Examples:

 background-origin: padding-box /* default value */
 background-origin: border-box 
 background-origin: content-box

Examples:

CSS 3 gradients

<div height="100px" 
     style="background: linear-gradient(top, #eff484 0%,#1e5799 100%);">
Hello
</div>

The following example shows the kind of code that you now have to insert for dealing with current and last generation browsers.

 
background: #eff484; /* Old browsers */
background: -moz-linear-gradient(top,  #eff484 0%, #1e5799 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eff484), color-stop(100%,#1e5799)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #eff484 0%,#1e5799 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #eff484 0%,#1e5799 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #eff484 0%,#1e5799 100%); /* IE10+ */
background: linear-gradient(top,  #eff484 0%,#1e5799 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eff484', endColorstr='#1e5799',GradientType=0 ); /* IE6-9 using ActiveX */

Border images

  • Firstly, you need to set the with of the border, i.e. rather large
  • The border-image property then will reuse these values
  • The stretch keyword means that the image should be stretched to match the sizes above.

Example:

 
 border-style: solid;
 border-color: #930;
 border-width: 20px 40px 40px 40px;
 border-image: url(frame.png) 20 40 40 40 stretch stretch;
 -webkit-border-image: url(frame.png) 20 40 40 40 stretch stretch;
 -moz-border-image: url(frame.png) 20 40 40 40 stretch round;

Tools and links

Tools

Firefox color picker
  • ColorZilla includes an Eyedropper, ColorPicker, Page Zoomer and other colorful goodies.
Gradient Generator
  • CSS3 gradient generator is on-line tool (free) for creating CSS 3 gradients. It generates both CSS3 code and four vendor-specific codes that one could use before CSS is fully implemented.

Introductions

Color

Reference

CSS specification pages at W3C:

Color tables: