I am currently studying spectral lines and saw in my notes that the way in which the absorbtion line spectra for a star was measured was by taking its light and shining it through a cold gas. The remaining light would show a black body spectrum with dark lines at the wavelengths which correspond to an exact difference in energy levels between two orbitals for an electron.
My question is, isn't this sort of spectroscopy supposed to identify the elemental composition of the star? It seems to me this would identify what elements were in the cold gas instead.
Note: I am asking whether the measured absorption spectra represents the stars or the cold gas. If it measures the stars, why? Wouldn't changing the gas change the wavelengths at which electrons will make a transition?