All Snippets
Top 100 Snippets

By Language

GBIC >> Source Code >> HTML >> Snippet

12 Colors

..Colors in Windows programs are represented by a 24 bit number, consisting
of 8 bits for each of the colors Red, Green, and Blue.  This allows computers
to display about 16.8 million colors,

The 8 bits simply means that the value for each of the Red, Green, or Blue
components can be any number from 0 to 255.

There are two basic ways to write the value of a color - as regular number
(0 to 16,777,216) or as a hexadecimal string.  HTML is normally written
using the hexadecimal string for a color.

To get the hexadecimal string representing a color, simply concatenate the
hexadecimal representation of each Reg, Green, Blue component as follows
(note the pound sign in front of the hex color string):

Color HEX  Color RGB
#000000   R, G, B values are 0, 0, 0 (black)
#FF0000   R, G, B values are 0, 255, 0 (red)
#00FF00   R, G, B values are 0, 255, 0 (green)
#0000FF   R, G, B values are 0, 255, 0 (blue)
#C0C0C0   R, G, B value are 192, 192, 192 (dark gray)
#FFFFFF   R, G, B values are 255, 255,255 (white)

The W3C HTML specification supports 16 standard colors, which
can be use by name anywhere an HTML attribute requires a color:

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

Most browsers additionally support names for a larger number of colors than
the W3C standard.

Web Safe Colors
At one time, when many computers were limited to 256 display colors, attempts
were made to standardize on 216 Web Safe Colors (not 255 so as to allow for
OS reserved colors).  This standard is of little value now.