Ionic bonding occurs when valence electrons are transferred from metal atoms to non-metal atoms, resulting in positively charged cation and negatively charged anion ions that are attracted via electrostatic forces. Ionic compounds form when a metal donates its valence electrons to a nonmetal. The electrostatic attraction between opposite charges holds the ions together. Common ionic compounds include sodium chloride, formed from sodium cations and chloride anions, and magnesium oxide, formed from magnesium cations and oxide anions.