Spectroscopy uses sound, particle or light emissions to provide information about the properties of matter. Astronomers split light into its component colors, called a spectrum, using an optical instrument called a spectroscope. The component colors of a star tell scientists what elements comprise a star and how fast it's moving.
Elements absorb light at different wavelengths, resulting in dark absorption lines on the spectrum. Each element gives a different pattern of absorption lines. The colors displayed and the line patterns reveal what the star is made of.
For the purposes of spectroscopy, stars are classified according to their surface temperature. Hotter stars give off more light. Sir Patrick Moore, in his book, "Atlas of the Universe," defines 12 classifications, although he states that sometimes R and N are grouped together and called C. Heather Couper and Nigel Henbest, in their book, "Space Encyclopedia," define seven spectral types.