Refraction is the bending of a beam of light when it enters a medium of different density. Light travels fastest in vacuum and in air. When light enters a medium of higher density, such as water, its velocity changes and causes it to bend or refract.
The angle at which the light bends depends on the density of the new medium relative to the medium that the light was originally traveling in. This is because light travels slower in a denser medium, which causes light to refract more. For example, if light is traveling in air and then encounters water in its path, it slows down because water is denser than air, and this change in velocity causes light to bend very slightly. If light is traveling from air to glass, instead of to water, it bends to a greater degree because glass is denser than water and causes light to slow down more than water does. In both these cases, the beam of light bends towards the "normal," which is simply a line drawn perpendicular to the boundary between air and water or air and glass. If light were traveling from a denser medium to a rarer medium, like water to air, then light would speed up when reaching air and would bend away from the normal. This phenomenon of light bending due to a change in its velocity is called refraction.