Multiply the element's atomic mass by the number of atoms of that element in the compound. This will give you the relative amount that each element contributes to the compound. For hydrogen chloride, HCl, the molar mass of each element is 1.007 grams per mole for hydrogen and 35.453 grams per mole for chlorine.