Stars of different temperatures appear to shine with different colours. This is similar to what happens when you heat up a lump of metal to very high temperatures. After heating the metal for some time, it will start to glow red. As it gets hotter still, that red will evolve into yellow, then white and eventually the metal will be glowing a bright blue colour. In the same way, it turns out that blue stars are very hot and are therefore classed as 'O' stars, whereas the cooler, red stars, are placed into the 'M' class.
When we think about our star, the Sun, we picture it as being yellow. It is therefore not surprising to discover that the sun is classed as a 'G' star, with a temperature of approximately 5,500°C. The following table lists the different classes of stars, along with their approximate temperatures and colours.
Stars can be more accurately categorised under this system, by the addition of a number between 0-9 to the group letter. For example, G2 (the Sun’s more precise spectral class) is hotter than G7, but cooler than a G0. Similarly, a B9 star is cooler than a B4.