The rising of liquid through a narrow space against the pull of gravity is called the capillary action or capillarity. Capillary action results from a competition between the intermolecular forces within the liquid (cohesive forces) and those between the liquid and walls of tube which has narrow or little diameter (adhesive forces).
Movement of water into a small capillary tube is a process in which primarily, there occurs the H–bonding between the silicon dioxide (SiO2), and the water molecules. As a result adhesive forces (H–bonding) between the wall and water molecule which are stronger than the cohesive forces within the water will direct the water to creep up the wall of glass tube. At the same time the cohesive forces that give rise to surface tension pull the liquid surface up. These adhesive and cohesive forces combine to raise the level of water and produce the familiar concave meniscus. The liquid raises up to a point where the gravitational pull of earth balances the adhesive forces which pull downward.
On the other side if you place a glass capillary tube in a dish of mercury, the mercury level in the tube drops below that in the dish. Because, mercury has a higher surface tension than water due to its stronger cohesive forces (metallic bonding). The cohesive forces among the mercury atoms are much stronger than the adhesive forces (mostly dispersive) between mercury and the SiO2(glass). So, the liquid tends to pull away from the walls. At the same time, the surrounding atoms are being towards the interior of mercury by its high surface tension, so the level drops. These combined forces result in the curved meniscus of mercury.