When light passes through gas in the atmosphere some of the light at particular wavelengths is scattered resulting in darker bands. These lines came to be known as 'spectral lines' and were cataloged by heating common elements until they produced light and measuring the wavelengths emitted.
Each of the different colors has its own wavelength, which reflects and refracts at its own angle, different from all the other colors. When light passes through a prism (a triangular piece of glass), it is reflected and refracted into a continuous band of colors called a spectrum.