The speed of light in a vacuum is a constant, defined as cvac = 2.998×108 m/s. However, when light is travelling through a medium other than a vacuum, its propagation speed may be (and is likely to be) different. The speed at which light propagares through a particular material is defined by the material's refractive index, n. The refractive index of a material nmat, describes the ratio of the speed of light in a vacuum divided by the speed of light in that material.
$${n_{mat} = \frac{c_{vac}}{c_{mat}} }$$The speed that light propagates through any medium other than a vacuum also depends upon the light's frequency. Therefore, a material's refractive index depends upon the frequency of the light as well. For example, the refractive index of quartz glass is about 1.65 at 1500 THz (200 nm vacuum wavelength), but 1.54 at 500 THz (600 nm vacuum wavelength) (ref). If you find a table of refractive indices for different materials where the frequency of the light is not mentioned, typically the value was measured with a low-pressure sodium lamp which emits monochromatic light at about 509 THz (589 nm vacuum wavelength).
When light changes speeds, its wavelength must change as well. Remember the relation between a waves speed, frequency, and wavelength:
$${c = f \lambda}$$A photon of light's energy depends upon its frequency, and energy must always be conserved. Therefore, it is the wavelength that must change to keep the above equation balanced when light enters a new medium. For example: Orange-appearing 500 THz light has a wavelength of 600 nm in a vacuum, but a wavelength of only 390 once it enters quartz glass.
Energy isn't the only thing that must be conserved when light slows down: so must its momentum. This principle can be used to explain why light bends when it passes from air into water.
The conservation of momentum can be used to explain why waves bend (refract) when they change speeds. The momentum of a wave can be calculated from its energy divided by its speed:
$${p = \frac{E}{c} }$$The x-component (the component parallel to the interface) of the momentum of a wave incident on a surface can be related to the total momentum using trigonometry:
$${p_x = p \sin(\theta)= \frac{E}{c}\sin(\theta) }$$Since the x-component of the momentum of the incident wave must equal the x-component of the momentum of the transmitted wave:
$${ \frac{E_i}{c_i}\sin(\theta_i)=\frac{E_t}{c_t}\sin(\theta_t) }$$Energy must be conserved, and thus the energy of the incident and transmitted photons cancel. Plugging in the equation for refractive index, Snell's law of refraction is obtained:
$${ n_i\sin(\theta_i)=n_t\sin(\theta_t) }$$Since the refractive index of a material is a function of wave frequency, each frequency will refract at a different angle when entering a new medium. This is called dispersion, and results in a spatial separation of frequencies, such as what happens to white light in a prism. Note that if the light passes from air into a flat sheet of glass with parallel faces, the refraction from glass back to air will exactly cancel the refraction from air to glass, leading to no spatial separation of the light frequencies. This is why prisms are triangular, or some other shape that does not have parallel faces.
Dispersion also results in a spreading out of the wave frequencies over time. If a wave pulse is created in time by superimposing waves of different frequencies, the width of the pulse in time will change as each component wave of the superposition is phase shifted due to propagating through the medium at different speeds.