Here's why:
* Metals tend to lose electrons, becoming positively charged ions (cations).
* Non-metals tend to gain electrons, becoming negatively charged ions (anions).
The electrostatic attraction between these oppositely charged ions is what forms the ionic bond and creates the solid ionic compound.
Examples of ionic compounds:
* Sodium chloride (NaCl): Sodium (Na, a metal) loses an electron to chlorine (Cl, a non-metal), forming Na+ and Cl- ions, which then attract each other to form the salt we know.
* Calcium oxide (CaO): Calcium (Ca, a metal) loses two electrons to oxygen (O, a non-metal), forming Ca2+ and O2- ions, which then attract each other.
Note: There are exceptions to this rule, where metal-nonmetal combinations can form covalent compounds. This happens when the electronegativity difference between the metal and non-metal is small. However, ionic compounds are far more common.