The electron configuration for magnesium is 1s2 2s2 2p6 3s2. Electron configuration is a representation of how electrons are arranged in an atom or molecule.
By looking at an atom's electron configuration, it is possible to determine how many energy levels the atom has, how many electrons are in each energy level and how many electrons are in the atom's outer energy level.
When looking at each part of an atom's electron configuration table, the first number refers to the energy level. The lowercase letter refers to the sub-shell. The second number refers to the number of electrons in a particular sub-shell. The first part of the magnesium electron configuration — 1s2 — indicates there are two electrons in sub-shell p of the first energy level.
From this electron configuration, it is easy to determine how many electrons are in each energy level. The number of electrons in each energy level is equivalent to the number of electrons in each sub-shell. In the first energy level, sub-shell s holds two electrons.
The second energy level has two sub-shells: s and p. There are two electrons in sub-shell s and six in sub-shell p for a total of eight electrons in this energy level. The third energy level has two electrons. They are found in sub-shell s. This is a total of 12 electrons.
In a neutral atom, the number of electrons must equal the number of protons so there is no net charge. The atomic number of magnesium is 12; therefore, a neutral atom of magnesium has 12 protons and 12 electrons.