When you look at the spectrum of sunlight, you will see a blend of colors. This is called a continuous spectrum. This is like a rainbow, produced when sunlight passes through raindrops, which act as prisms.
The science of spectroscopy starts in the lab, where scientists observe the spectra of different elements with the spectroscope. What scientists noted is that each element or compound have their own signature spectrum. So, when observing a star, astronomers use a spectroscope to definitively determine what elements make up that star, among other things about the star.
Compare the spectra of hydrogen, helium. Oxygen, and neon, below. Look at the lines; this is the key to determine which element’s spectrum you are observing. Each spectrum is specific to that element. It is like fingerprints; no two are alike.
When one captures the Sun’s spectra, it includes all of the elements and compounds found in the Sun.
Astronomers employ stellar spectroscopy to study stars, which allows them to determine many of the physical and chemical properties of the stars and other objects they study in space. (1)