I’ll cover your question in 2 parts. The first step is the spectral bands. Inside an atom, there are a number of electrons around the nucleus. There are many different patterns the electron cloud can form. The patterns have a different energies. An electron in a higher energy pattern tends to fall back to the lowest-energy pattern. The extra energy has to go somewhere, so it sends out a photon. A photon is a little bit of light. The color of the photon depends on the amount of energy the atom releases.
The reverse also happens. A photon can come along and get absorbed, putting the electron back in a higher-energy state.
There are a number of possible jumps that can happen in each atom, but the neat thing is that each atom is different. So the light it emits is like a person’s fingerprint. If you look at the light, you can usually tell what atom it came from. That’s how scientists can tell what a star is made of. They look at it’s spectral "fingerprint." For example, Hydrogen has a very well known spectrum. It emits light at 656.2nm (red), 486.1nm (blue-green), 434.0 (blue-violet), and 410.1nm (violet). The last one is hard to see because it is almost at the edge of what our eyes can pick up.
The next part of your question was about Red and Blue shift. This is the same thing the "Doppler shift" you are probably familiar with already, although you may not recognize the name. Think of what you hear when you are standing by the side of the road and a car drives by going pretty fast. The sound of the car changes as it passes you, from a higher pitch to a lower pitch. When something is traveling toward you while emitting waves (like light or sound) you hear (or see) the frequency as being higher that you would if the source was at rest. In the same way, when something is traveling away from you while emitting waves you measure the frequency as being lower that you would if the source was at rest. Since the universe is expanding, all parts of it are moving away from each other. This means that when we look a star in a distant galaxy, for example, it is moving away from us and the "fingerprint" light from that star seems to have all of its spectral features at lower frequency that normal. Since the color red is in the low frequency end of the visible spectrum, astronomers call this "red shift" since the frequencies we measure are lower (i.e. redder) than usual. By measuring how much lower, we can figure out how fast the star is moving away from us.
Adam & Mats
(republished on 07/19/06)
If the observed spectrum were more or less continuous then it might be difficult to convince you that there was a red shift. But it's not. Different atoms have very distinct signatures called 'lines' that arise from the discreet energy levels of electrons in the atom. Hydrogen, for example, has sets of spectral lines called series. The photo shown below is that of the Balmer series.
Now if you see this particular pattern but each line is shifted down in frequency by the same ratio then you should conclude that the hydrogen gas was moving away from you. The relative velocity is related to the amount of the shift. Now making a plot of this shift versus the known, or derived distance to a few nearby galaxies gives a linear plot whose slope is called the Hubble Constant.
There is a very nice article you might enjoy here: https://en.wikipedia.org/wiki/Redshift
(published on 06/19/13)