When light goes through different transparent substances, it appears to bend or change direction; for example, when it goes from air to water or vice versa. This phenomenon is called refraction. Refraction happens at the interface of two substances, i.e. where the substances meet (their boundaries). However, if light passes through the interface vertically (at a 90 degree angle), refraction does not occur. The straw in the picture below looks broken because of refraction. Additionally, on sunny days, it looks like there is water on the road ahead when travelling by car; this is also due to refraction and it is called mirage.
Water or glass are more dense materials than air, so light slows down when it travels from air into glass or water, and it speeds up when it enters air from glass or water. The diagram below is essential to understanding refraction of light, so study it carefully.
The green and red lines show the speed and direction of light in air and water, whereas the dotted line needs to be drawn on the diagram by us, so we can calculate the angles of incidence: A and C (when light hits the different medium) and the angles of refraction, B and D (when light comes out of the interface). In the first diagram, A is bigger than B (A > B), because water is denser than air. In the second diagram, D is bigger than C (D > C), because air is less dense than water, so light speeds up when it enters air.