When the light passes from one media into another media, the light beam is bent or refracted according to Snell's Law and the index of refraction of the material.
The speed of light is slower in various materials than it is in a vacuum.
The index of refraction of the material is defined as $n=\frac{c}{v}$, where $c$ is the speed of light in vacuum and $v$ is the speed of light in the material. The light is refracted because the speed of light is changed at the boundary.

The speed of light through a material varies slightly with frequency of the light. Thus, light with different frequency are refracted at a slightly different angle. This spreading out of the beam of light is called dispersion or chromatic dispersion.
Normally, we only see light with wavelength between 400nm-700nm. (This is the wavelength of light in vacuum, when light enter a material, the wavelength of light will changed because the speed of light is changed while the frequency of the light is always the same.)
The following applet show light enter a prism with different refraction index for different color of light (red:1.513,1.514,yellow:1.517,green:1.519,blue:1.528,1.532)

You can drag the arrow with mouse to change the location and direction of the light.
Angle of the prism can be adjusted with dslider bar.
Click [b]play[/b] to see the slow motion of light and see the dispersion occurs.
When the simulation is paused. You can change the direction of light, click play again to see another dispersion effect.