CSS - Colours

December 2016

Colors

The CSS standard offers different ways to define colors:

Applying a color with its name

HTML has names set for a limited number of colors (see HTML colors). The number of colors offered by HTML is not sufficient for every need; however, it may be practical to invoke colors using their name when they are standard colors.

The CSS standard includes the 16 basic colors defined by HTML 4.01, and adds orange. The list of colors available in CSS is:

aqua green orange white
black lime purple yellow
blue maroon red  
fuschia navy silver  
gray olive teal  

So to set level-1 headers as blue, simply add a CSS rule such as the following:

h1 {color: blue}

Browsers actually support more than 140 color names, but at present, they are not all part of the CSS standard.

RGB code in hexadecimal notation

More than 16 million colors can be defined by specifying a color's RGB values using the notation #RRGGBB, drawn from HTML, where RR, GG and BB each represent a hexadecimal number between 00 and FF for Red, Green, and Blue, respectively.

Here is the same declaration as above, with hex notation:

h1 {color: #0000FF}

RGB code in decimal notation

CSS also defines a "functional" RGB notation, which is used to set red, green, and blue values by indicating their relative proportions as a percentage or as positive integers (each value can be an integer between 0 and 255), with either of the following syntaxes:

rgb(100%,100%,100%)
rgb(24,125,255)

Related :


CSS: Colores CSS
CSS: Colores CSS
Couleurs CSS (RGB)
Couleurs CSS (RGB)
CSS - I colori
CSS - I colori
CSS -As cores
CSS -As cores
This document entitled « CSS - Colours » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.