This is similar to what happens to sound. Imagine that a fire engine is driving past you with its siren on. When it is moving towards you, the siren it quite high pitched. When it is moving away from you, the pitch drops and it sounds lower. With light, "lower" means more red and "higher" means more blue.
You can see what this looks like in the diagram below, where two galaxy spectra are compared.
In fact, the further away a galaxy is, the faster it appears to be moving, and hence the more the spectrum is redshifted. Astronomers can, therefore, measure the distance to a galaxy by taking a spectrum and seeing how much the lines that you would expect to see have been shifted.