One of Isaac Newton's (1654-1727) experiments with light involved allowing sunlight to pass through a prism, which created a rainbow pattern; Newton concluded that the white light of sunlight actually contained all the colors mixed together.
By the mid 1800's scientists could make finer and finer prisms, and they discovered that the rainbow was not a continuous flow of colors; there were sections separated by vertical dark lines. Spectroscopy is the study of these lines; it involves measuring the resulting lines that are produced when matter interacts with or emits light.
The breathrough came about when scientists realized that the pattern of lines, or the line spectrum, acted as a fingerprint for each element -- that by examining the light that was produced by something, its elemental components could be determined.
Around the 1860's, sunlight again was examined, and having studied the line spectra of hydrogen on Earth, scientists showed that hydrogen was present in the Sun. They discovered an additional line spectra of an unknown element, which was named Helium (from Helios, Greek god of the Sun.) Several years later, Helium was discovered underground on Earth.