Ionic bonding occurs between metal and non-metal atoms when they form ions. Metals form positive ions by losing electrons, filling their outer electron shells. Non-metals form negative ions by gaining electrons. The oppositely charged ions are attracted in an ionic compound via electrostatic forces. Sodium chloride is an example where sodium atoms lose electrons to become Na+ ions and chloride atoms gain electrons to become Cl- ions. The ions are arranged in a crystal lattice structure held together by ionic bonds.