system
Given the following post, respond as if you're commenting on Reddit:
human
How can we tell how far a star is?

Hi,I know about redshift, though I can't understand how we can tell how much that light has redshifted if we don't know its original state. In other words, we can observe only the light that travelled that long way to us, and due to doppler effect it has shifted a bit. I read the defition of redshift, and it says  it happenens when the frequence of light is lower than when it was emitted. But we don't actually know what its original frequence was, right? I know this may sound a stupid question to you, but I can't realize it by myself.
gpt
We can actually say what the frequency of the broadcasted light was. The spectrum of starlight doesn't consist of a single frequency, nor is it constant and continuous. It has peaks and valleys at different frequencies. The locations of these depend on the material. We know that hydrogen absorbs light at very specific frequencies, so any light passing through a concentration of hydrogen will show a dip at those frequencies, because part of the light with those frequencies was absorbed by the hydrogen.

Now, we know that stars are made of mostly hydrogen and helium, so we can predict what the spectrum of a star looks like. When the light gets redshifted, the gaps in the spectrum get redshifted along with it. By identifying the frequencies of things like hydrogen absorption lines in the redshifted spectrum, we can determine exactly how much the light was redshifted.