The number of electrons in an element is determined by its atomic number. The atomic number of an element represents the number of protons in the nucleus of an atom of that element. Since atoms are electrically neutral, the number of electrons in an atom is also equal to its atomic number.
For example, the element hydrogen has an atomic number of 1, which means it has one proton in its nucleus and one electron surrounding the nucleus. Oxygen has an atomic number of 8, indicating that it has eight protons and eight electrons.
The periodic table of elements is arranged in increasing order of atomic number, allowing us to determine the number of electrons in an atom of any element by referring to its position on the table.