Stars are grouped into 7 main categories (also called, classes). These were created by astronomer Annie Jump Cannon. The classes are called O, B, A, F, G, K and M. Stars in the 'O' class are the most massive and hottest, with temperatures above 30,000 °C. Stars in the 'M' class are the smallest and coolest, with temperatures below 3,000 °C.
If you look closely at stars in the sky, you notice they are not all the same colour. Some appear redder and some appear bluer. The colour of light a star gives off, is controlled by its temperature. Hotter 'O' stars glow bluer, and cooler 'M' stars glow redder. This is similar to what happens when you heat up metal to very high temperatures. As the metal heats up, it will start to glow red. As it gets hotter, that red becomes more yellow, and then white. Eventually, the metal will be hot enough to glow a bright blue colour.
Our closest star, the Sun, shines with a yellow light. The Sun is classed as 'G' star, with a temperature of about 5,500 °C.
We can be even more accurate when we categorise stars by splitting each class into 10 smaller sub-classes. These sub-classes are numbered 0 - 9, with 0 being hotter than 1. For example, the Sun is actually a G2 star. This is hotter than a G7 star, but cooler than a G0 star. Similarly, a B9 star is cooler than a B4 star.
The table on this page lists the average temperatures and colours for each class of star.