Why does magnesium oxide have no overall electrical charge?

Created from Britannica articles using AI. AI can make mistakes, so verify using Britannica articles.

Magnesium oxide (MgO) has no overall electrical charge because it is an ionic compound formed by the electrostatic attraction between oppositely charged ions that balance each other out.12

When magnesium reacts with oxygen, the magnesium atom loses two electrons to become a positively charged cation (Mg2+), while the oxygen atom gains those two electrons to become a negatively charged anion (O2−). Because the total number of electrons lost by the magnesium must equal the total number of electrons gained by the oxygen, the resulting compound maintains a net zero charge. In the solid ionic lattice structure of magnesium oxide, these positive and negative ions are arranged so that their charges alternate and perfectly balance one another, ensuring the entire substance remains electrically neutral.312