DISPERSION OF LIGHT
The underlying principle for the formation of these colours is shown above in picture. When white light passes through glass [here a prism], it refracts as it enter and leaves the glass, and split into a spectrum of colours. You should notice that the colours merge into one another, and they are not all of equal widths in the spectrum. A rainbow is just a naturally occurring spectrum. White light from the sun is split into a spectrum of colours as it enters and leaves droplets of water in air. It is also reflected back to the viewer by total internal reflection, which is why you must have the Sun behind you to observe a rainbow.
The splitting up of white light into a spectrum is known as dispersion ['spreading out']. IsaacNewton set out to explain how it happens. It had been suggested that light is coloured by passing through a prism. Newton showed that this was a wrong idea, by arranging of a spectrum to be passed back through another prism. He concluded that white light is a mixture of all the different colours of the spectrum.
So what happens in a prism to produce a spectrum? As the white light enters the prism, it slows down. We say that it is refracted and, as we have seen, its direction changes. Dispersion occurs because each colour is refracted by a different amount. Violet light slows down the most, and so it is refracted the most. Red light is least affected.