The atoms of any element consist of three different types of particles known as neutrons, protons and electrons. When electromagnetic radiation falls on atoms it is absorbed by the electrons in the atoms. Electrons exist around the nucleus of the atom in specified orbitals each of which has a specific energy state. When atoms absorb or release electromagnetic radiation, electrons move from one orbital to another. The frequency of radiation emitted is equivalent to the difference in energy between the orbitals that electrons can exist in.
An atom can absorb radiation only of specific frequencies that correspond to the difference in the energy of levels of any two orbitals that the electrons can exist in. When the atom absorbs radiation the electrons move from an orbital with a lower energy state to one with a higher energy state. This forms the absorption spectral lines. Similarly, when electrons move from an orbital with a higher energy state to one with a lower energy state a specific frequency of radiation is emitted. These form the emission spectral lines.