CSS colors may also be represented as a hex triplet, where the members represent the red, green and blue components of a color. Each of these values represents a number in the range of 00
to FF
, or 0
to 255
in decimal notation. Uppercase and/or lowercase Hexidecimal values may be used (i.e. #3fc
= #3FC
= #33ffCC
). The browser interprets #369
as #336699
. If that is not what you intended but rather wanted #306090
, you need to specify that explicitly.
The total number of colors that can be represented with hex notation is 256 ^ 3 or 16,777,216.
color: #rrggbb;
color: #rgb
Value | Description |
---|---|
rr | 00 - FF for the amount of red |
gg | 00 - FF for the amount of green |
bb | 00 - FF for the amount of blue |
.some-class {
/* This is equivalent to using the color keyword 'blue' */
color: #0000FF;
}
.also-blue {
/* If you want to specify each range value with a single number, you can!
This is equivalent to '#0000FF' (and 'blue') */
color: #00F;
}
Hexadecimal notation is used to specify color values in the RGB color format, per the W3C's 'Numerical color values'.
There are a lot of tools available on the Internet for looking up hexadecimal (or simply hex) color values.
Search for "hex color palette" or "hex color picker" with your favorite web browser to find a bunch of options!
Hex values always start with a pound sign (#), are up to six "digits" long, and are case-insensitive: that is, they don't care about capitalization. #FFC125
and #ffc125
are the same color.