Planck's law gives the intensity of the energy radiated by a blackbody as a function of wavelength and temperature. As the temperature of a blackbody increases, the peak wavelength shifts from red to blue. Extremely hot blackbodies emit most of their energy in the ultraviolet range, while cool blackbodies emit primarily in the infrared. Stars behave like blackbodies, so their color follows their temperature, too. Stars similar to the sun (with a temperature of about 5800 Kelvin) appear nearly white because the visible part of the intensity curve is nearly flat.
Snapshot 1: Cool stars are orange or red.
Snapshot 2: Medium temperature stars are nearly white.
Snapshot 3: Hot stars are blue.
Wolfram Demonstrations Project
Published: April 25 2007