Sunday, 11 March 2012

Hex triplet

A hex leash is a six-digit, three-byte hexadecimal cardinal acclimated in HTML, CSS, SVG, and added accretion applications, to represent colors. The bytes represent the red, blooming and dejected apparatus of the color. One byte represents a cardinal in the ambit 00 to FF (in hexadecimal notation), or 0 to 255 in decimal notation. This represents the atomic (0) to the best (255) acuteness of anniversary of the blush components. Thus web colors specify colors in the Truecolor (24-bit RGB) blush scheme. The hex leash is formed by concatenating three bytes in hexadecimal notation, in the afterward order:

Byte 1: red amount (color blazon red)

Byte 2: blooming amount (color blazon green)

Byte 3: dejected amount (color blazon blue)

For example, accede the blush area the red/green/blue ethics are decimal numbers: red=36, green=104, blue=160 (a greyish-blue color). The decimal numbers 36, 104 and 160 are agnate to the hexadecimal numbers 24, 68 and A0 respectively. The hex leash is acquired by concatenating the 6 hexadecimal digits together, 2468A0 in this example.

Note that if any one of the three blush ethics is beneath than 16 (decimal) or 10 (hex), it charge be represented with a arch aught so that the leash consistently has absolutely six digits. For example, the decimal leash 4, 8, 16 would be represented by the hex digits 04, 08, 10, basic the hex leash 040810.

The cardinal of colors that can be represented by this arrangement is 256 × 256 × 256 = 16,777,216.

An abbreviated, three (hexadecimal) chiffre anatomy is sometimes used.5 Expanding this anatomy to the six-digit anatomy is as simple as acceleration anniversary digit: 09C becomes 0099CC. This allows anniversary blush amount to awning its abounding ambit from 00 to FF. The three-digit anatomy is declared in the CSS specification, not in HTML. As a result, the three-digit anatomy in an aspect added than "style" is not interpreted as a accurate blush in some browsers.

No comments:

Post a Comment