On closer inspection of the continuous spectrum received from stars, astronomers see that there are dark lines in it, absorption lines.
Above is a spectrum of our sun in the range of visible light.
Atoms that contain electrons around the nucleus can have different energy states.
These energies are discrete in the sense that only very specific energy levels are possible. Atoms can change their energy state by either absorbing energy from incoming photons, or can emit energy in the form of photons. But both absorption and emission of energy only happens over discrete energy quanta.
Compare this with a henhouse. When everything is quiet, the hens (electrons) are in their ground state. But if they are disturbed by an outside influence (photon radiation) they can jump up to any of the energy levels where they can be. They cannot be just about anywhere, they have to be on one of the prescribed energy levels.
If light from the star shines through the outer layer, then atoms in that outer layer can absorb photon energy. This means that in the light that comes through to us, specific photon energies (wavelengths or colours) are missing or at least much less intense than other wavelengths.
Each atom has its own specific possibilities of change between energy levels and therefore each chemical element has its own specific “barcode” of dark lines, called absorption lines.
|Looking at a star we see the absorption spectrum that originates from the outer layer, against the background of the continuous spectrum.|