The gaps within an absorption spectrum occur when the light that is measured has passed through a medium that has absorbed some photons. The photons that the medium absorbs are specific to the element that the medium is made of. This is because the energy from the absorbed photons (E=hf) is used to raise the electrons in the medium's structure to the next energy level. The energy required to do this is the gap between energy levels and has to be equal to the exact photon's energy hence only allowing certain photons to be absorbed. With only photons of certain frequencies/wavelengths being absorbed this leads to gaps within a spectrum of the light that is measured. Commonly, light propagating through space will pass through cooler gasses such as hydrogen that will conduct this phenomena.