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.