To understand what light and other EM waves can tell us, we have to understand how they are made.
All matter is made of atoms which include a central nucleus surrounded by electrons in energy levels. It is electrons that are involved with EM waves. If energy is applied to an electron around an atom, this electron will absorb the energy, and it will move out of the energy level that it is in normally, its ground state, to a higher energy level, the excited state. Sooner or later, this excited electron will decay back to its ground state. As it decays it will give off the difference in energy as a pulse of EM radiation, a photon of a certain frequency. Any time an atom absorbs any kind of energy ( be it heat, mechanical, or electromagnetic) that atom will emit EM radiation.
If atoms are in contact with each other in a dense material, solid, liquid or gas, the atoms will vibrate and collide. The electrons, being the same charge and repelling each other will be jostled out of their energy levels and as they return, will give off all different frequencies of EM radiation. Such a dense object will emit all frequencies, a continuous spectrum
If atoms are separate from each other, the electrons can only move between energy levels within the same atom. Because each atom, ion or molecule has a finite number of electrons, there are only a finite number of frequencies that are given off when the electrons drop to lower energy levels. This spectrum is a bright line spectrum. Both continuous and bright line spectra are created when atoms give off EM radiation and are called emission spectra.
Atoms can also absorb EM energy. If a continuous spectrum shines through a non-dense gas, this gas will absorb the same frequencies it would give off if it emitted. So the continuous spectrum would show these particular frequencies missing, as black gaps in the continuous spectrum. Such a spectrum is called an absorption spectrum or dark line spectrum.