How does looking at a spectrum tell us what a star is made of?
If you place a prism close to a light bulb, you will observe a continuous spectrum of colors, which is basically the composition of white light.
However, if a gas was the source of the radiation, you will see absorption lines. These absorption lines are due to the atoms of the gas atmosphere.
Now different elements can absorb different wavelengths. Thus, Astronomers Compare these lines with the absorption lines absorbed by elements on earth. eg. Hydrogen, Helium, and Sodium
Is it answering your question?