To determine an element's molar mass, it is necessary to add together the weight of all of the atoms present in the sample. The atomic weight of an element is printed inside the element's box on the periodic table. The molar mass is the atomic weight multiplied by the number of atoms per mole.
For many elements, this calculation is simple. Oxygen, for example, has an atomic weight of almost exactly 16. Oxygen forms molecules of two atoms, so the molar mass of O2 is 32 grams per mole. To obtain an absolute mass, it is necessary to know how many atoms are present in a single mole and how many moles are present in the sample.
To determine this, it is necessary to apply a function known as Avogadro's Number. This is expressed as an equation, 6.022×10^23, that can be used to compute the number of moles per gram or kilogram. Hydrogen, for example, has an atomic mass of 1. A single mole of hydrogen therefore has a mass of 1 x 6.022×10^23. Carbon has an atomic mass of 12, so 6.022×10^23 atoms of carbon have a mass of 12 grams.
This formula works as well for molecules. A single molecule of water consists of one oxygen atom and two hydrogen atoms. Therefore, one mole of water is equal to one mole of oxygen, 6 x (6.022×10^23), and two moles of hydrogen, 2 x (6.022×10^23).