Well... Here is the solar spectrum - much more professional and beautiful than the one I provided.
<img src="https://solarsystem.nasa.gov/system/resources/detail_files/390_highresolutionsolarspectrum1200w.jpg">
All these black spots, are spectral lines - and you see they happen in different colors.
Now - different color = different energy.
Red - lowest energies, Blue - highest energies.
All elements and atoms can only absorb a photon with specific amount of energy. Meaning - on a wavelength 656.3 nm we have a hydrogen line (Hα) H-alpha. (red color), there is a green line of Iron, K, Mg and stuff.
Also, Helium is found first on the Sun, using spectral lines, and then found on earth, hence the name Helios-Helium. But yeah, we have all the lines of the elements in periodic table - in lots of variations. and simply matching them with the spectra we get (with wavelengths they are), we can say hey... THe sun has IRON (Fe) which is ionized 11 times (misses 11 electrons).
Here is a nice stuff to read on for more info and probably better explanation:
https://www.explainxkcd.com/wiki/index.php/1733:_Solar_Spectrum
If you have more questions shoot :)