HTML and CSS Reference
In-Depth Information
meaning as the intensity of the primary colors increases, the color becomes lighter
and lighter (the lightness is added to) until eventually it becomes white. To define
color in a web browser, each primary color is stored in a byte, or 8 bits (8 ones and/or
zeros). Each color component (red, green, and blue) then has the possible values in
the range of 00000000 to 11111111, which is the range 0-255 in decimal. 0 is com-
plete lack of the color, while 255 is the fullest possible intensity of the color. Decimal
is a base-10 counting system, meaning ten digits (including 0) are used before count-
ing moves position. Binary is a base-2 system, meaning only two digits are present
(0 or 1). Base-16, hexadecimal, has 16 digits that can be used to compress a binary
number, such as 1111, into one digit: F. The following table shows the first 16 digits
of each numbering system:
The value 255 in decimal can be represented as 11111111 in binary or FF in hexa-
decimal. Obviously, at two digits long, hexadecimal wins as the most compact rep-
resentation of the number 255. Pure white, which is the combined full intensity of
red, green, and blue, can be represented as red = 255, green = 255, and blue = 255,
or in hexadecimal as red = FF, green = FF, and blue = FF. Condensed all together we
get FFFFFF. Add a hash sign to the beginning, and this is the hexadecimal notation
used for colors on the Web. The range of colors available in this system is 256 × 256
× 256 (or 2563), which equals 16,777,216 possible colors. (256 is used here instead
of 255, because the calculation needs to factor in zero in each color component.)
Note There is a handy color utility named ColorZilla ( )
that integrates into Firefox and provides several features such as an in-browser color
picker, web page color scheme analyzer, and even a tool for creating CSS gradients!
Hexadecimal notation can also represent color using three digits when a digit is re-
peated in each of the color components. So, magenta could also be represented as
#f0f . White, which is #ffffff in hexadecimal, can be optionally shortened to #fff .
#99aaff (a light blue) could be shortened to #9af , and so forth.
It is also possible to use a preset color keyword such as white , black , aquamar-
ine , and so on. While modern web browsers support dozens of keywords for choos-
ing colors, for the sake of consistency stick with precisely defining your colors (through
hexadecimal notation or otherwise) to ensure they are the same as what appear in your
Search WWH ::

Custom Search