CSS Colors

CSS Colors

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.

Colors in CSS are most often specified by:

1) Color Name - like "red"

2) RGB Value - like "rgb(255, 0, 0)"

3) HEX Value - like "#ff0000"

1) Color Names

Colors set by using color names:

Example:

    
    

2) RGB (Red, Green, Blue)

RGB color values can be specified using this formula: rgb(red, green, blue).

Each parameter (red, green, blue) defines the intensity of the color between 0 and 255.

Example:

     
    

3) Hexadecimal Colors

RGB values can also be specified using hexadecimal color values in the form: #RRGGBB, where RR (red), GG (green) and BB (blue) are hexadecimal values between 00 and FF (same as decimal 0-255).

For example, #FF0000 is displayed as red, because red is set to its highest value (FF) and the others are set to the lowest value (00).

Note: HEX values are case-insensitive: "#ff0000" is the same as "FF0000".

Example:

    
    

Web Safe Colors

Here is the list of 216 colors which are supposed to be most safe and computer independent colors. These colors vary from hexa code 000000 to FFFFFF.