For example, consider the ionic compound sodium chloride (NaCl). Sodium atoms lose one electron, becoming positively charged sodium ions (Na+). Chlorine atoms gain one electron, becoming negatively charged chloride ions (Cl-). When sodium and chlorine atoms combine to form sodium chloride, the positive charge of the sodium ions is equal in magnitude to the negative charge of the chloride ions, resulting in an overall neutral electric charge.
The attraction between the positively and negatively charged ions in an ionic compound is called electrostatic force or ionic bonding. This force holds the ions together and maintains the structural integrity of the compound.
It's important to note that the neutral charge of an ionic compound is a macroscopic property that applies to the compound as a whole. On the microscopic level, the individual ions within the compound retain their respective charges. However, the arrangement and stoichiometry of the ions are such that the overall net charge is zero.