Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
A color hex code is a way of specifying color using hexadecimal values. The code itself is a hex triplet, which represents three separate values that specify the levels of the component colors. The code starts with a pound sign (#) and is followed by six hex values or three hex value pairs (for example, #AFD645). The code is generally associated with HTML and websites, viewed on a screen, and as such the hex value pairs refer to the RGB color space.
A color hex code describes the composition of a certain color in a specific color space, usually RGB. In the case of RGB, the first value pair refers to red, the second to green and the third to blue, with decimal values ranging from 0 to 255, or in hexadecimal 0 to FF (#RRGGBB). RGB is an additive color space, meaning that when all three colors are put together the result is white (white light). For example, the color hex code for white is #FFFFFF or in decimal 255, 255, 255; and at the opposite end is black #000000. Yellow is made up of red and green, so its hex code is #FFFF00. Other color spaces using hex codes include:
The codes can also be represented in a three-digit code to represent double values in CSS. For example, #FFFFFF can be abbreviated as #FFF and #00AA55 as #0A5. This is defined in the CSS specifications, so it only works under the "<style >" tag when used within HTML. The notation reduces the palette to 4096 colors (12 bits) as opposed to 16,777,216 colors (24 bits) for the six-digit coding.