Spectrum from prism:
Sunlight is often called white light, since it is a combination of all the visible colors. Since the index of refraction is different for each color, the angle of refraction will be different for each color when the light passes from air into glass or other transparent material. This is according to Snell's Law.
Now if the piece of glass has parallel sides--such as with a window--the light will return in the same direction that it entered the material. But if the material is shaped like a prism, the angles for each color will be exaggerated, and the colors will be displayed as a spectrum of light.
When Prism spreading white light into a spectrum of light, The visible colors are in the order of the spectrum. You can remember the order by the name VIBGYOR.
Note that in the illustration above, the colors are distinctly separated. In realty, they blend into each other, such that there are colors in between. For example, there is red-orange in between red and orange.
Explanation:
Light of all colours have the same velocity in vacuum or air. But in any other medium, velocity is different for different colours of light. For example, in glass the velocity of red light is the greatest and that of violet light is the least. So, the refractive index of glass for violet light will be greater than that for red light. Thus deviation of violet light becomes maximum and that for red light becomes minimum while passing from air to prism. Deviations for other five colours lie in the range between the deviations of these two colours. So, the different in refractive indices of a medium for different colours of light results in the formation of spectrum.