Flexi Says: Nearly all magma contains trapped gases. When the magma is under great pressure deep beneath Earth's surface, the gases are part of the liquid solution. As the magma plume moves upward and the pressure lowers, the trapped gases stars to expand. When the magma reaches the low pressures at Earth's surface, the expanding gases can form bubbles and foam in the erupting lava. This action is somewhat similar to opening a bottle of carbonated water or soda. When the bottle is sealed, the gases are trapped in the liquid at high pressure. When the bottle is opened up to the surrounding air, the pressure quickly decreases and the gases expand to form bubbles.