How do color name codes work in programming?


Quick Answer

Color name codes, or hex color codes, work to tell the computer which combinations of red light, green light and blue light to display on the computer screen. A hex code has six digits, comprised of three two-digit number and letter combinations that represent red, green and blue, respectively. Each two-digit number or letter combination represents a level of each color on a scale that goes from the numbers zero to nine, then from the letters “A” to “F.”

Continue Reading

Full Answer

In hex color codes, a value of zero is the lowest color saturation and a value of “F” is the highest. For instance, the hex code #FFFFFF represents white as the brightest possible shade of the three main colors, whereas a hex code of #000000 represents black as the darkest possible shade of all three main colors. Using hex codes, #FF000000 represents pure red and #0000FF represents pure blue. Abbreviated hex codes work the same way as full-length hex codes do, but only have three digits. Each of the three digits represents a pair of identical digits—for example, #0F0 represents #00FF00.

Hex codes derive their name from the hexadecimal number system, which refers to the two-digit system of counting. Through this system, only two digits are able to represent 256 shades of each base color.

Learn more about Computer Programming

Related Questions