Color value (Advice)

Color values can be specified numerically or mnemonically.

Property/method value type:String primitive

A numeric color specification is a 6 digit (3 pairs) hexadecimal value with a leading hash symbol. Each pair of digits defines the intensity of a single color (RGB) in the display.

The web-safe palette of 216 colors is defined by every possible combination of the following values:

00, 33, 66, 99, CC and FF

There are other values supported through the mnemonic named color palette, which includes 100 shades of gray.

You can use non-web-safe values if you have a greater than 8 bit deep display. These days most platforms can resolve at least 16 bits, but some legacy systems may have problems resolving non-web-safe colors.

When using color values for defined styled colors, the rgb() function can be used.

In the MSIE browser, the values can also be specified as 32 bit integer values, although in practice this is extremely difficult to manage.

In certain circumstances, where an alpha value is available, the color value can be specified using hexadecimal notation to define a 32 bit integer. In this case, the value is comprised of four pairs of hex digits as follows:

0xAARRGGBB

The value AA controls the alpha channel transparency, while the RR, GG, and BB values are the intensity of Red, Green and Blue respectively.

When passed as a string value, the same hexadecimal value can be used but must be preceded by a hash rather than the 0x prefix. Thus 0xAARRGGBB becomes #AARRGGBB

Warnings:

See also:Colour names, rgb()