In 1811 Amedeo Avogadro proposed that equal volumes of different gases at the same temperature and pressure contain the same number of molecules. This is now called Avogadro's law.
A container of hydrogen and an identical container of carbon dioxide at the same temperature and pressure therefore hold the same number of molecules, even though a carbon dioxide molecule is 22 times as heavy as a hydrogen molecule.
Turned around, the law says that one mole of any gas takes up the same volume when the temperature and pressure are the same.
At 0 °C and 1.013 × \mathrm{10^5} Pa, which is normal atmospheric pressure, one mole of a gas takes up about 22.4 L, the volume of a cube with sides of about 28.2 cm.
This volume, 22.4 L/mol, is called the molar volume of a gas. It is almost the same for every gas, as Avogadro's law says.
A gas expands when it is warmed. At 25 °C and the same pressure, one mole takes up about 24.5 L, so the temperature and pressure always have to be stated with a molar volume.
In liquid water the molecules touch one another, about 0.3 nm apart. In a gas at 0 °C and 1.013 × \mathrm{10^5} Pa, the molecules are on average about 3.3 nm apart, about ten times as far.
The molecules themselves therefore fill less than 0.1 % of the volume of a gas. Almost all of a gas is empty space, so the size of the molecules makes hardly any difference to the volume.
What sets the volume is the number of molecules, together with the temperature and pressure. This is why equal numbers of molecules of different gases take up the same volume.
The density of a gas at 0 °C and 1.013 × \mathrm{10^5} Pa, in grams per litre, multiplied by 22.4 L/mol gives the mass of one mole, so the molar mass of a gas can be found by weighing it.
A 1.00 L flask is weighed after the air is pumped out, then weighed again filled with an unknown gas at 0 °C and 1.013 × \mathrm{10^5} Pa. The difference, 1.25 g, is the mass of 1.00 L of the gas.
The molar mass is 1.25 g/L × 22.4 L/mol = 28.0 g/mol, so the gas could be nitrogen, \mathrm{N_2}, or carbon monoxide, \mathrm{CO}. In the same way, oxygen, 32.0 g/mol, has a density of 32.0 ÷ 22.4 = 1.43 g/L.
At 0 °C and 1.013 × \mathrm{10^5} Pa, dividing the volume of a gas by 22.4 L/mol gives its amount, and multiplying an amount by 22.4 L/mol gives the volume. The amount then connects with mass and number of particles as before.
For 11.2 L of carbon dioxide, the amount is 11.2 L ÷ 22.4 L/mol = 0.500 mol, and the mass is 0.500 mol × 44.0 g/mol = 22.0 g.
The number of molecules is 0.500 mol × 6.02 × \mathrm{10^{23}} /mol = 3.01 × \mathrm{10^{23}}. At other temperatures and pressures, the molar volume for those conditions is used instead of 22.4 L/mol.