This exercise says that the characters of a hex code represent values for red, green, and blue. How does this work?

Question

This exercise says that the characters of a hex code represent values for red, green, and blue. How does this work?

Answer

The hexadecimal system uses 16 digits rather than 10 to represent numbers. Within this system f represents the highest value, f = 15.

The first two digits of the hexadecimal value are red, the second green and the last two are for blue. Hence, the following hexadecimal values map as follows:

#FF0000 → Red
#00FF00 → Green
#0000FF → Blue