When the electrons in the element are excited, they jump to higher energy orbits. As the electrons fall back down, and leave the excited state, energy is re-emitted, the wavelength of which refers to the discrete lines of the emission spectrum. Note, however, that the emission extends over a range of frequencies, an effect called spectral line broadening.
The emission spectrum can be used to determine the composition of a material, since it is different for each element of the periodic table. One example is identifying the composition of stars by analysing the received light.
An absorption spectrum occurs when light passes through a cold, dilute gas and atoms in the gas absorb at characteristic frequencies; since the re-emitted light is unlikely to be emitted in the same direction as the absorbed photon, this gives rise to dark lines (absence of light) in the spectrum. The light emitted from an excited atom can not be directed toward the observer, so the light appears to be missing from the continuous spectrum.