The technology is too involved to reproduce colours using the seven basic colours of the rainbow. Instead it was considered good enough to use only the colours red (r), green (g) and blue (b). Take a look at the colour inks for your printer and this will be what you get. To reproduce "almost" every color and shade of colour the computer uses a 6-digit hexadecimal numbers. That is xxxxxx. The combination is rrggbb. So the front two digits controls the amount of red, the middle two digits the amount of green, and the back two digits the amount of blue.
Each digit (that is each column) of the hexadecimal has sixteen elements. The normal counting has only 10 elements per unit. That is you count only count from zero to nine and then you will come to the next unit. In hexadecimal you count from zero to fifteen before you come to the next unit (that is the next column).
If we want to fully use the combination allowed, to maximise the numbers and shade of colors, we will have to specify sixteen elements per digit (per column). So we use "0" (zero) up to "9" (zero) and then continue with "a" up to "f". This will give us sixteen elements.
Each of the color will start from "ff" and gets progressive dark as it approaches "00". So #000000 is black and #ffffff is white. We can get 256 different colours and shade of colours with any combination in between.
Of course how the computer will interpret the code will depend on the software. For example a colour may appear nice in Windows but not so in Apple's MacIntosh. But there are certain common grounds. A rule of thumb is; the colour codes 3, 6, 9, c, and f are common. Their combinations are sometimes referred to as safe palette.
It must also be noted that some browsers can understand simple colour code like "white", "black", "red". "green", "blue", etc..