Spectral lines are the result of interactions between a quantum system (usually atoms, but sometimes molecules or atomic nuclei) and single photons. All spectra and spectral lines arise from transitions between discrete energy states of matter, as a result of which photons of corresponding energy (and hence characteristic frequency or wavelength) are absorbed or emitted. From the energy levels thus determined, atomic and molecular may be studied. A photon is absorbed when it has the correct energy to allow a change in the energy state of the system (in the case of an atom it is usually an orbital jump of an electron); then it will be re-emitted spontaneously, or in the same frequency as the original or in cascade, where the sum of the energy of the emitted photons will be the same as the absorbed photon. The direction of the new photons will not be in relation to the direction of the original photon.
Depending on the geometry of the gas, the source of the photon and the observer, either an emission line or an absorption line will be produced: if the gas is between the photon source and the observer, a drop in light intensity is observed in the frequency of the incident photon, since the re-emitted photons will be in different directions than the original. This is an absorption line. If the observer sees the gas, but not the photon source, he will only see the photons re-emitted in a narrow frequency range. This is an issue line.
The absorption lines and the emission lines are extremely atom-specific and can be used to easily identify the chemical composition of all the means that light can pass through (usually gases). They also depend on the physical conditions of the gas and therefore are widely used to determine the chemical composition of stars and other celestial bodies that cannot be analyzed by other means, as well as their physical conditions.
Other mechanisms, besides atom-photon interaction, can produce spectral lines. Depending on the physical interaction (with molecules, single particles, etc.) the frequency of the photons involved varies widely, and the lines can be observed along the entire electromagnetic spectrum, from radio waves to gamma rays.
An absorption line is a dark line in a continuous spectrum that corresponds to the absorption of light, or some other form of electromagnetic radiation, at a well-defined wavelength; the pattern of such lines is characteristic of specific atoms or molecules in the path of the radiation. If a light source with a continuous spectrum is viewed through a cool gas then dark lines appear in the spectrum. The wavelengths of the lines are identical to the wavelengths of emission lines from the same gas when heated. Spectral lines are often used to identify atoms and molecules.
The pattern of absorption lines in a spectrum is diagnostic of the types of atoms and molecules present, for example, in the surface layers of a star or the atmosphere of a planet. Absorption lines are seen in the spectra of the Sun and other stars. Most of them are Fraunhofer lines but some arise in the cool interstellar gas along the line of sight and give clues to the physics and chemistry of the interstellar medium. Absorption lines in quasars carry information about intergalactic space.