CSS - Colours

February 2017


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:



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, titled "CSS - Colours," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).