Elements in the sun absorb specific, signature, wavelengths.....
Spectroscopy involves analysing the light from the sun. Any hot body, such as the sun, will emit a band of continuous wavelengths as a result of its temperature ("black body radiation"). The elements present in the sun, such as hydrogen and helium absorb specific, discrete, wavelengths that are particular to that element. Hence when the light from the sun is analysed, these signature wavelengths are missing and this allows us to determine which elements are present in the sun.