We can distinguish two kinds of spectra:
  1. The absorption spectrum
  2. The emission spectrum
Light with a certain (variable) wave lenght is sent through the investigated substance. At some wave lenghts, the substance will absorb part of the light. The consequence will be that the outcoming light is poorer in radiation of the light with that particula wave lenght(s).
A detector will notice that and op the plotter (grafic) can be seen a peek going down in the grafic.

The exited molecules are not stable and will (fast) fall back in the basic situation, the ground stand. During that back fall, new radiation is emitted (in all directions). Also this emission radiation can be detected (in the drawing with an angle of 90 degrees) and put in a grafic. You can see peeks up.

The pattern of a spectrum often shows what molecule is involved. They are kind of finger print of the molecules and atoms.