Here's why:
* Metals tend to lose electrons and form positively charged ions (cations).
* Halogens tend to gain electrons and form negatively charged ions (anions).
The strong electrostatic attraction between the oppositely charged ions results in the formation of an ionic bond. This bond is characterized by the transfer of electrons from the metal to the halogen, leading to a stable compound.
For example, in the formation of sodium chloride (NaCl), sodium (Na) loses an electron to become a sodium ion (Na+), while chlorine (Cl) gains an electron to become a chloride ion (Cl-). The resulting electrostatic attraction between the two ions forms the ionic bond.