As light travels through different materials, it scatters off of the molecules in the material and is effectively slowed down. The amount by which light slows in a given material is described by the refractive index, n. The refractive index of a material is defined by the speed of light in vacuum c divided by the speed of light through the material v:
n = c/v
So, when light passes through air, the index is 1.0003, through water is 1.330 and glass 1.520. As a beam of light enters another medium, it is refracted or bent. The part of the light beam that strikes the medium appears to slow down, causing the entire beam to bend. The more sharply the beam bends, the more it appears to slow down. Of course, when light passes from a substance of high density into one of low density, its speed appears to increase, and it bends away from its original path.
Each colour has a different wavelength, and each colour bends differently from other colours. Short wavelengths are slowed more sharply upon entering glass from air than are long wavelengths. Red light has the longest wavelength and is bent the least. Violet light has the shortest wavelength and is bent the most. Thus violet light travels more slowly through glass than does any other color and red light travels fastest.