When a full spectrum of light (all the colours, like the light of the sun) passes through the sample, which is often a gas, some specific colours do not show up on the other side. These colours of light are being absorbed by the sample. An image is created of the spectrum of light with black breaks where the light has been absorbed. These breaks are called absorption lines, and every element has its characteristic pattern of absorption lines.
On an atomic scale, this happens because of the electrons in the atoms of the sample - an electron can absorb light to gain energy. However, the model of the atom says that an electron's energy must fit onto set, quantised, discrete energy levels. The process of an electron going to a higher energy level is called excitation. For any atom of a particular element, the energy needed to excite an electron from one specific energy level to another will be the same. This is important because it allows us to compare the absorption lines of say, the atmosphere of a far away planet, to the absorption lines of elements we know to exist in a lab. We can then reach a conclusion about what the planet's atmosphere may be made of.
The missing colours give us information about the energy of the photons that cause excitation. Note that the energy gained by the excited electron is equal to the energy of the incident photon (a particle of light), so only photons with fitting energies will cause an excitation. The energy of a photon is directly proportional to its frequency:
Where E is the energy of a photon, h is a constant (a set number that doesn't change) and f is the frequency of the photon. Since a colour can be described as a specific frequency of light, this is why the black breaks can be used to identify element(s) which the light is passing through.
The intensity of the absorption varies as a function of frequency, and this variation is the absorption spectrum.
In chemistry, the technique is used to detect and measure concentrations of a particular metal element within a solution. The scientists atomise the sample (make it turn to individual atoms) and then see what light wavelengths it absorbs. Each type of chemical (element) absorbs a particular wavelength, so scientists can tell which chemicals are in the sample. Every element has a different atomic absorption spectrum because of the different light wavelengths it absorbs.