Computer monitor screens consist of a rectangular array of pixels, each of which can have a particular colour. The colour of a pixel can be expressed as a triple (e.g. (34,56,128)) which describes the intensity of three component colours: red, green, and blue (RGB) (which correspond to the three electron beams in the monitor). By choosing various combinations of intensity of these component colours, different hue and shades can be constructed.
The scale of each component colour can vary depending on your video hardware, but for the purposes of discussion, it's safe to assume that the each component colour is selected from an 8-bit range of [0,255] or a 16-bit range of [0,65535]. Here are some examples using an 8-bit range:
R G B 0 0 0 - Black. 255 0 0 - Red. 0 255 0 - Green. 0 0 255 - Blue. 0 0 50 - Dark blue. 255 255 0 - Yellow. 255 255 255 - White.
To get a feel for this system, try editing the colour table of an image in Graphic Converter. You can enter colour intensities for the three colours and see what you end up with.
If an 8-bit range was used for each colour is employed, the raw space (e.g. before compression) required to store an image would be three bytes per pixel. For high quality images, this is necessary.
However, as many images do not contain a wide variety of colours, it's possible to select a "palette" of just a few hundred colours from the millions available and use just them in the picture. Such a palette is called a colour table. Using a 256-entry colour table, each pixel can be represented by just one byte - a third of the size. The image then can be represented as a colour table plus a byte for each pixel. The colour table consists of 256 entries (numbered 0..255), each of which contains three bytes which define the RGB colour for that entry. This is the way GIF works.
For images that contain even fewer colours, it's possible to use even narrower colour tables. For example, if an image contains just sixteen different colours, one 16-entry colour table can be used and each pixel can be represented by just four bits.
Sometimes you'll hear people refer to "system colours" or the "system colour table". This usually means a colour table whose entries have been constructed to provide a uniform spread of colours across the three RGB dimensions. It's the sort of colour table you'd get if you built it like this:
for red = 0 to 255 step 50
for green = 0 to 255 step 50
for blue = 0 to 255 step 50
write(red,green.blue);
The colour table idea is such a powerful one that it's actually been built into the hardware of the monitors of most personal computers. Monitors (or more precisely video cards) can be configured to employ a variety of colour table sizes. For example, my Macintosh hardware supports colour tables with 2, 4, 16, 256, and 65536 (I think) entries. So you'll hear people talking about their monitor being in "8-bit" mode or "256 colour mode". Some video systems with lots of memory actually abandon the colour table system and allow three 8-bit (or ten-bit) values to be specified for each pixel.
When a webbrowser displays a page containing images, it has to juggle the colours in the images and the colours in the hardware colour table that exist (or can be set) so as to produce the best effect. Usually it does this by dithering the colour, or by converting each image colour to the "nearest" colour available on the colour map.
Although colour tables of many different sizes are possible, the three most commonly used sizes are 2 colours (black and white), 256 colours, and "millions" of colours (which usually means three 8-bit values per colour and doesn't involve a colour table at all). If you experiment with these with real images, you'll find that 256 colours is really not good enough to accurately represent many real photographs. The only exceptions are photographs of landscapes and other homogenous lumps of colour where the colours tend to be restricted to a small part of the spectrum. For example, a landscape of green would probably look OK in 256 colours. But botanic gardens in full bloom would probably look awful.
For this reason, it's nearly always best to use JPEG for any photographic image.
Unfortunately, a large number of computer monitors (particularly
PC ones) can't display any more than 256 colours. So if you include
sophisticated JPEG images containing many colours, you should be aware
that they may be reduced to 256 colours prior to being displayed on the
user's monitor.