The percentage by mass of an element in a compound is calculated by dividing the total mass of the element in one mole of the compound by the molar mass of the compound and multiplying by 100%.