Image of the whole sky as seen by the Cosmic Microwave background Explorer Satellite (COBE) which was taken in 1992 to show that the Big Bang which created the Universe was not uniform and contained fluctuations
Stars and galaxies emit visible light which can be split up into its component colours to form a spectrum. Lines appear in this spectrum corresponding to the existance of different elements in the source of the light. If the source were stationary then the lines are in a particular pattern, which corresponds to the pattern produced by the same elements as are emitting light, on the surface of the Earth.
If the source of light is moving towards the Earth then the wavelength of all the emitted waves is compressed a little. This results in a shift of the spectral lines into the blue part of the spectrum, known as a blue shift. Conversely if the source of the light is moving away from the Earth then there is a shift of the lines into the red part of the spectrum known as a red shift, due to the wavelength of the emitted light all being extended a little.
Stars and Galaxies Life Cycle of the Stars