Why do astronomers utilize spectroscopy to analyze distant galaxies?

Answer

To identify chemical elements through their unique spectral barcodes

Spectroscopy is a technique that splits incoming light to reveal the chemical composition of an object. Different elements, such as hydrogen, oxygen, and helium, absorb and emit light at specific, known wavelengths, creating a unique barcode or fingerprint. By observing where these lines appear, astronomers can determine the chemical makeup of a galaxy and measure how much those lines have been shifted from their rest position, which indicates the degree of redshift.

Why do astronomers utilize spectroscopy to analyze distant galaxies?
lightgalaxyuniversecosmologyredshift