Heat a piece of iron and it first glows a dull red, then orange, then close to white. Nothing about the iron has changed except its temperature, and yet the color changes. A star does the same thing.
A hot body does not emit at one wavelength alone. It emits at every wavelength at once, but not in equal amounts. Draw how much comes out at each wavelength and the shape is a single curve with one hump. This is the blackbody curve, and its shape is fixed by the temperature and by nothing else.
Raise the temperature and the hump slides toward the short wavelengths. Lower it and the hump slides toward the long ones. That sliding is what the eye reads as a change of color.
The eye only takes in the stretch from about 380 to 780 nm. That is a narrow window on the whole curve, so what we call the color of a star is a glimpse of one part of it.
Where the hump sits can be written down exactly. Multiply the wavelength of the peak by the temperature and the answer is always the same number. Written in nanometres and kelvin, \lambda_{\max} T = 2.9 \times 10^{6}. This is called the Wien displacement law.
Put the numbers in. The sun at 5800 K peaks at about 500 nm, which is the middle of the visible window. A red star at 3000 K peaks at about 970 nm, out in the infrared. A blue star at 30000 K peaks at about 97 nm, out in the ultraviolet.
So for most stars the peak itself is not visible at all. What the eye sees is the side of the hump, and it is the slope of that side across the visible window that decides whether a star looks reddish or bluish.
The law runs the other way just as well. Measure the color and the temperature follows. No distance is needed for this, which is why temperature is the first thing that can be pinned down about a star.
The curve gives one more thing. Add up the area under it and that is the total energy leaving each unit of the surface every second. That total is E = \sigma T^4, the Stefan-Boltzmann law, and \sigma is a fixed number.
A fourth power is steep. Raise the temperature by half, to 1.5 times, and the area goes up about 5 times. Double the temperature and it goes up 16 times. A small change in temperature is a large change in output.
The whole star emits from its whole surface, so the luminosity also carries the surface area: L = 4\pi R^2 \sigma T^4. Temperature and radius together fix the luminosity, and nothing else enters.
This one equation is what the lines of equal radius on the HR diagram are drawn from. Two stars at the same temperature but different brightness can only differ in radius.
Spread the light of the sun out finely enough and the band of color is not smooth. Narrow dark lines are cut into it at fixed places. Fraunhofer counted hundreds of them at the start of the nineteenth century, long before anyone knew what they were.
The light itself comes from deep inside, where the gas is dense, and it comes out carrying every wavelength. On the way out it passes through the thin gas of the outer layers, and there the atoms take back the particular wavelengths they are able to absorb.
Which wavelengths an atom can take is fixed by the steps its electrons can climb. The steps differ from element to element, so hydrogen cuts its lines in one set of places and sodium and calcium in others. The pattern is a signature.
That makes the dark lines a way of reading what a star is made of, from here. Helium was found in the spectrum of the sun before anyone had found it on the earth, which is where its name comes from.
Stars were first sorted by how strong their hydrogen lines were and labelled A, B, C and on down the alphabet. Later the classes were merged and put in a different order, and the surviving sequence is O, B, A, F, G, K, M.
What the reordering did was put them in order of temperature. O is the hottest at around 40000 K and M the coolest at around 3000 K. The sequence that started as a filing scheme turned out to be a physical one.
The hydrogen lines are strongest in class A, at about 9000 K, and fall away on both sides. Hotter than that, the hydrogen is ionised and has no electron left to absorb with. Cooler than that, the electrons stay on the lowest step and cannot take the wavelengths in question. Only in between are the lines strong.
Each class is split further from 0 to 9, so the sun is a G2 star. The horizontal axis of the HR diagram in the next article is this sequence, and reading it is reading temperature.