Hydrogen and oxygen combine in the ratio of 1:8 means that 1g of hydrogen gas requires 8g of oxygen gas to form water.
Therefore, 3g of Hydrogen gas will require = 8 * 3
= 24 g of oxygen
Thus, 24g of the oxygen gas would be required to react completely with 3g of hydrogen gas to form water.