| PreviousUnits | CSS - Colours | NextBlock elements and borders |
The CSS standard offers different ways to define colours:
HTML has names set for a limited number of colours (see HTML colours). The number of colours offered by HTML is not sufficient for every need; however, it may be practical to invoke colours using their name when they are standard colours.
The CSS standard includes the 16 basic colours defined by HTML 4.01, and adds orange. The list of colours 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 colour names, but at present, they are not all part of the CSS standard.
More than 16 million colours can be defined by specifying a colour'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}
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)