If a picture is worth a thousand words then, to an astronomer, a spectrum is worth a thousand pictures.
Every substance absorbs or emits light with specific characteristics.
The light collected from celestial objects by a telescope is passed through a spectrograph which separates the light into different colors or wavelengths. Spectra look like supermarket bar codes, and the arrangement of lines tells us about the composition, density, temperature and motion of gases. Vital information about stars can only be detected in ultraviolet light which contains, in particular, the signature of hydrogen, the most abundant gas in the universe. Luckily for the sensitive skins of humans, UV light from the Sun and stars does not penetrate far into the Earth's atmosphere. That's why we need telescopes in space.