A spectral line is a dark or bright line in an otherwise uniform and continuous spectrum, resulting from an excess or deficiency of photons in a narrow frequency range, compared with the nearby frequencies.
Spectral lines are the result of interaction between a quantum system (usually atoms, but sometimes molecules or atomic nuclei) and single photons. When a photon has exactly the right energy to allow a change in the energy state of the system (in the case of an atom this is usually an electron changing orbitals), the photon is absorbed. Then it will be espontaneously reemited, either in the same frequency as the original or in a cascade, where the sum of the energies of the photons emitted will be the same as the energy of the one absorbed. The direction of the new photons will not be related to the direction of travel of the original photon.
Depending on the geometry of the gas, the photon source and the observer, an emission line or an absorption line will be produced. If the gas is between the photon source and the observer, the latter will observe a decrease in the intensity of light in the frequency of the incident photon, as the reemitted photons will be in directions different than the original one. This will be an absorption line. If the observer sees the gas, but not the original photon source, he will see only the photons reemitted in a narrow frequency range. This will be an emission line.
Absorption and emission lines are highly atom-specific, and can be used to easily identify the chemical composition of any medium capable of letting light passing through it (typically gas is used). They also depend of the physical conditions of the gas, so they 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 than atom-photon interaction, other mechanisms can produce spectral lines. Depending on the exact physical interaction (with molecules, single particles, etc.) the frequency of the involved photons will vary widely, and lines can be observed across all the electromagnetic spectrum, from radio waves to gamma rays.
A line extends on a range of frequencies, not a single a frequency. The reasons for this broadening are several: