Alkali metals tend to lose an electron to reach the noble gas electronic configuration, becoming positive ions. On the other hand, the halogens reach this configuration by adding an electron to their valence shell, becoming negative ions. The union of positive and negative ions by electrostatic forces generates a crystal lattice, an ionic compound.
Thus, lithium fluoride (LiF) is obtained when lithium (1s 2 2s 1 ) gives up one of its valence electrons to fluorine (1s 2 2s 2 2p 5 ), forming the lithium cation (1s 2 ) and the fluoride anion ( 1s 2 2s 2 2p 6 ). As can be seen in the electronic configurations, the lithium cation is isoelectronic to helium and the fluoride anion is isoelectronic to neon.
Using Lewis symbols
Let's see as a second example the formation of calcium oxide, CaO
Using Lewis symbols: