Spectroscopy is a way of using focused light to get a light-fingerprint of compounds. Spectroscopy is also used to identify the composite elements of distant stars, based on the strengths of specific light frequencies the stars emit.
Every star has a unique fingerprint based on the elements making it up. If two stars had the exact same makeup, the two light fingerprints or spectra would be identical.
Each element on the period table creates a unique spectra of light. This information can be used to identify precisely which elements constitute a given light source.
These observations are possible because of what we know about prisms. Issac Newton, in his age-old classic Opticks, talked about diffraction through a prism. It's famous from the album The Dark Side of the Moon (by Pink Floyd), and the knowledge of light as it gets separated passing through a prism has been invaluable to mankind. The length of glass through which the pure original light passes through varies, and this variance engenders and coaxes light of various frequencies to show its amplitudinal strength and vibrancy at particular nodes. A pure and balance light can illuminate the whole spectrum, while certain stars, gasses, and various light sources can shine intensely at particular frequencies of light while being completely absent in others.
The separation of the bands of light from full spectrum light, as show in an animation using particles (photons) for light. Some animations prefer wiggles (or "waves").