By listening to the ambulance’s siren, we can tell if the ambulance is coming or going. When an ambulance approaches with a siren, the sound wave’s wavelength becomes shorter (higher note), and when it moves away, the wavelength of the sound wave becomes longer (lower note).
Similar effects are seen in light. As the star moves away from the observer, the star light’s wavelength becomes longer than originally. Because of this, the spectrum of starlight appears to be skewed towards the red color (redshift). Scientists are analyzing the spectrum of light from outer galaxies to find out that the universe is expanding.