Here's why:
* Ionic bonds occur when one atom (usually a metal) loses an electron(s) to become a positively charged ion (cation), and another atom (usually a nonmetal) gains that electron(s) to become a negatively charged ion (anion).
* The opposite charges of the ions attract each other, forming a strong electrostatic attraction.
In the case of salt (NaCl), sodium (Na) loses an electron to become a positively charged sodium ion (Na+), and chlorine (Cl) gains that electron to become a negatively charged chloride ion (Cl-). These oppositely charged ions attract each other, forming the ionic compound sodium chloride (NaCl).