Answer: it depths on the Earth nearly and all the magmas contain gas dissolved in the liquid, but the gas forms a separate vapor phase when pressure is decreased as magma rises toward the surface of the Earth. This is similar to carbonated beverages which are bottled at high pressure. The high pressure keeps the gas in solution in the liquid, but when pressure is decreased, like when you open the can or bottle, the gas comes out of solution and forms a separate gas phase that you see as bubbles. Gas gives magmas their explosive character, because volume of gas expands as pressure is reduced. The composition of the gases in magma are:
Mostly H2O (water vapor) & some CO2 (carbon dioxide)
Minor amounts of Sulfur, Chlorine, and Fluorine gases
The amount of gas in a magma is also related to the chemical composition of the magma. Rhyolitic magmas usually have higher gas contents than basaltic magmas.
Explanation: was this help full