Here's how it works in the examples you provided:
* KCl (Potassium Chloride): Potassium (K+) is the cation, and chloride (Cl-) is the anion. The opposite charges attract each other, forming an ionic bond that holds the compound together.
* Salt Crystals (NaCl): Salt crystals are made up of sodium (Na+) cations and chloride (Cl-) anions. The attraction between these opposite charges creates a strong ionic bond that forms the crystal lattice structure.
In general, the electrostatic attraction between oppositely charged ions is what holds ionic compounds together.