Pressure outside the straw pushes against the water inside the straw and prevents it from dropping, according to University of California, Santa Barbara. The outside pressure has to sustainably overcome gravity to prevent the liquid from dropping.
The phenomenon can be replicated with a column of water that is up to 9.8 meters high. In a straw taller than 9.8 meters, cavitations would occur and gravity would overcome the air pressure. A partial vacuum on the upper part of the straw is partly responsible for the phenomenon. However, surface tension is more responsible for the extra free energy for every unit area of liquid-air interface.
As droplets form inside the straw, the surface area increases and the liquid stays in the tube. Capillary forces, which result from the liquid being attracted to the walls of the straw, help keep the liquid from spilling out. The forces play an important role because the straw has a large surface that is exposed to the liquid inside. If the diameter of the straw were increased, it would hold more liquid inside. A further increase in the liquid inside the straw would add weight to it, making it difficult for the combined effect of capillary forces and vacuum to prevent the liquid from spilling out. For these reasons the phenomenon would be hard to reproduce on a larger scale.