By observing changes in the color of the light stars emit, scientists can determine the speed of the stars and the direction they move in relation to Earth. The principle that explains the changes in color is closely related to a sound phenomenon we frequently experience here on Earth, the Doppler effect.
The Doppler effect is an observed change in pitch (how high or low a sound is) when either the source of the sound or the listener is in motion. Imagine a car, its horn blaring, approaching you as you sit on a park bench. To you, the sound of the horn seems higher in pitch than it would if the car were parked. As the car approaches you, the horn's pitch seems to be high, and if the car keeps the same speed, the pitch stays constant. As the vehicle passes by and moves away from you, the horn's pitch appears to drop.
In reality, though, the car horn vibrates at a constant rate, and to the person driving the car, the pitch doesn't change. You, however, hearing the sound from the bench, perceive a change because as the car gains ground on the sound waves traveling out from its horn, it pushes the sound waves together so that the sound wavelengths in front of the car get shorter. As wavelength shortens, frequency increases, so the higher the frequency is, the higher the pitch will be. As the car passes you, the sound waves traveling back toward you are spread out, and have a longer wavelength. This decreases their frequency and lowers the pitch you hear.
The Doppler effect applies to all types of waves, including light waves. Astronomers measure the Doppler shift in the frequency of the light stars emit, and from this information they can determine the stars' velocity and direction of motion in relation to Earth. In light, a change in wavelength and frequency is perceived as a change in color. For a star approaching Earth, increasing frequency makes the light appear bluer. This is known as a blueshift. If a star is moving away from Earth, decreasing frequency makes the light appear redder, which is known as a redshift. By measuring the extent of the change in color, an observer can also gauge how fast the star is moving: the faster it moves, the more pronounced the color shift will be. The discovery of redshifts in the spectra of galaxies in the 1920s led Edwin Hubble to conclude that the universe is expanding.