Colours on the Web

There are a number of ways to express colour values in CSS.

In that beautiful way that the universe has of making simple building blocks into almost infinite complexity, the screen you are reading this on mixes three colours to generate all the colours you can see on the monitor. If you look closely at the screen with a magnifying glass, you’ll see red, green and blue lights that display at various brightnesses. At the normal viewing distance the three lights will ‘merge’ and appear to be a single colour.

The colour value is stored using 8 bits for each of the three colours, meaning 24-bit storage for the whole bundle.

The following binary number represents the ‘reddest’ colour that can be produced: 111111110000000000000000.

Obviously, binary numbers are cumbersome for humans, so hexadecimal encoding comes to the rescue. Here’s how we convert a binary number to hexadecimal:

Four bits can be encoded by a single hexadecimal character. There are sixteen hex characters (0-15 or 0-F). The following table shows the binary to hexadecimal:

We encode 4 bits and use 8 bits per value for red, green and blue. So, 255 in denary becomes 11111111 in binary and FF in hexcode. Red: 255, Green: 255 and Blue:255 is white, which is represented in binary as 111111111111111111111111 or FFFFFF in hexcode.









Please find all references here.

Leave a Reply