At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
In short it's basically when an electron from the higher energy state drops into the lower energy state. \[\Delta E = hf\] The longer version explanation: The absorption of photons occurs where their energy matches one of the permitted energy transitions - their absorption provides the energy for electrons to 'climb' the set of permitted energy levels .. either directly or in stages between a lower and higher level. Since the set of permitted energy levels are specific and unique to a given element the range of specific absorptions/emissions are identical for all atoms of that element,so enabling different elements to be recognised and distinguished. When the absorbed photons are removed from incident light containing the full spectrum, their absence is seen as a series of fine black lines on an otherwise continuous spectrum background. So an emission spectra indicates the frequencies of emitted photons as electrons within the atoms return to their 'ground' states .. .. and absorption spectra record the absorption of electromagnetic radiation - as photons of specific energies, that put electrons into the higher, permitted energy levels within an atom.