Here's why:
* Metals tend to lose electrons, forming positively charged ions (cations).
* Nonmetals tend to gain electrons, forming negatively charged ions (anions).
The strong electrostatic attraction between these oppositely charged ions is what holds the compound together.
Examples of ionic compounds:
* Sodium chloride (NaCl): Sodium (Na) is a metal, and chlorine (Cl) is a nonmetal.
* Magnesium oxide (MgO): Magnesium (Mg) is a metal, and oxygen (O) is a nonmetal.
* Potassium bromide (KBr): Potassium (K) is a metal, and bromine (Br) is a nonmetal.
Let me know if you'd like to learn more about ionic compounds!