How many colors exist in the world?

Possible number of colors in web technology

We are talking only about the colors that can be represented in web technology. To find this out we must have an understanding of some basics about computer machines such as memory, color model and number systems.

Memory

Any character in a computer machine is represented using a byte which is 8 bits.

A way to verify the fact

1. Create a ‘sample.txt’ file in your computer machine.
2. Check it’s file size. It has to be 0 bytes ideally.
3. Edit the ‘sample.txt’ file and enter any three characters and save the file.
4. Now check the file size. It has to be 4 bytes. I guess the editor appends the End-of-Text character (ETX).
5. Edit the ‘sample.txt’ file again and remove one character and save the file.
6. Now check the file size. It has to be 3 bytes.
7. Repeat the steps 5 & 6, by removing one character until the file size is 0 bytes.

It is evident that 1 character is 1 byte.

Complementary question — “Why is a byte only 8 bits?”

RGB model

Every color is represented as a mixture of the primary colors — Red, Green and Blue.

Out of scope — Deeper level of study is needed to understand why RGB model is chosen as a web standard.

To represent a color we need to present the proportion of R, G and B. So we will require 3 characters to present a value for R, a value for G and a value for B.

As we know that every character takes 1 byte of memory which is 8 bits; for explanation purpose let’s represent a character in bits as 8 bits — _ _ _ _ _ _ _ _.

A bit can either be ‘0’ or ‘1’ — that’s how memory system is built.

The value of every bit can either be ‘0’ or ‘1’. So the proportion of Red can be in the range between 0000 0000 to 1111 1111. This gives a total of 256 possibilities. The same rule goes for Green and Blue as well.

256 * 256 * 256

Now we know that to represent a color we need the R, G, B values, and each can have a total possibility of 256 different values, so the total number of colors that can be manipulated is 256 * 256 * 256 = 16,777,216 ~ 16M.

The total number of colors has been calculated considering the RGB model — as it is the web standard.

Complimentary article

In HTML CSS, a color can be represented in multiple formats.

In the Hexadecimal system, equivalent of 0000 0000 is 00 and for 1111 1111 it is FF. The same can be represented in the Decimal system as 0 and 255 respectively.

So a color can be represented in Hex format for R,G,B values in the range of [00 00 00] up-to [FF FF FF], and in Dec format in the range of (0,0,0) to (255,255,255).

I have listed few of them here —

• Pure Green — rgb(0,255,0) or #00FF00 or simply#0F0
• Yellow — rgb(255,255,0) or #FFFF00 or simple #FF0
• White — rgb(255,255,255) or #FFFFFF or simple #FFF

Do let me know if my article needs correction / improvement. TIA.

learner. seeker.

learner. seeker.