The sum of protons and neutrons is the mass number. The mass of an atom is contained mainly within the nucleus where the protons and neutrons live. An electron's mass does not contribute significantly to the mass of the atom.
Each proton and each neutron is given an atomic mass of one. Because an electron has hardly any mass as at all, the mass number only takes into account the masses of protons and neutrons. The mass number is different for each isotope of an element. Isotopes are forms of the same element that have different numbers of neutrons in the nucleus. The atomic mass shown on the periodic table comprises the weighted average of an element's isotopes.