The Structure of Atoms

To understand spectral lines you have to understand some Atomic Physics.

Atoms and Spectra

One of Nature's most basic rules:

Systems naturally seek their lowest available energy state - or - logs roll downhill

Now, let's bombard an H atom with photons. What happens? Most of the photons go zipping right past without interacting with the H atom. But! photons with just the RIGHT energy get absorbed by the atom

Right means that the energy of the photon corresponds to the energy level difference between "allowed" orbits in the H atom. Absorbed means that the energy of the photon will now be gone and the atom will be in a higher energy state.