Each neutral atom of magnesium has 12 electrons. The electrons orbit around the nucleus, which contains the protons and neutrons.
Magnesium has an atomic number of 12. As long as the atom is neutral, the number of electrons is the same as its atomic number. The 12 electrons are arranged in three energy levels, or electron shells. The first shell has two electrons, the second shell has eight electrons, and the third shell has two electrons.
It is possible for magnesium to form ionic bonds with some elements. Ionic bonds are formed when one atom gives up electrons and the other gains electrons. For example, when magnesium combines with oxygen to form magnesium oxide, it gives up two electrons. This forms a magnesium ion with a positive charge.