Atoms want to be in the lowest possible energy state called the ground state (all electrons as close to the nucleus as possible).
Let's see how Bohr's model of the atom explains the three types of spectra. An emission line is produced by an atom in a ``excited'' energy state---the electron is not in as low an energy orbit as possible. Remember rule #3! In order to go to a lower energy orbit, the electron must lose energy of a certain specific amount. The atom releases the energy is the form of a photon with that particular energy. The energy of photon = the difference in energy of the energy orbits (energy ladder rungs).
Example: An atom with an electron at the E2 orbit and wants to get to the lower E1 energy orbit. It gives off a photon with energy E = h × f = E2 - E1. The electron may reach the ground state in one jump or it may temporarily stop at one or more energy levels on the way, but it canNOT stop somewhere between the energy levels. Different jumps produce photons of different energies. A larger jump to a lower energy level, will produce a photon with greater energy (smaller wavelength).
The atom produces light of certain wavelengths. (Remember that light is both a photon and a wave!) The more atoms undergoing a particular transition, the more intense the emission line will be. The intensity depends on the density and temperature of the gas.
An absorption line is produced when a photon of just the right energy is absorbed by an atom, kicking an electron to a higher energy orbit. The photon had energy = the difference in energy of the energy orbits. Because the energy levels in an element's atoms are fixed, the size of the outward jumps made by the electrons are the same as the inward jumps. Therefore, the pattern of absorption lines is the same as the pattern of emission lines. Other photons moving through the gas with the wrong energy will pass right on by the atoms in the thin gas. They make up the rest of the continuous spectrum you see.