Colours on the Web

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

Hexcode
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:

 

 

 

 

 

 

 

 


References

Please find all references here.

Leave a Reply