How do ionic compounds form?
An ionic compound forms when the electrons that bind two or more atoms together can lower their energy by spending more time around the more electronegative atoms than the electropositive ones, thereby causing partial negative and positive charges to develop on the atoms.
Atoms bind their electrons to the nucleus with different strengths, depending on subtle differences in the structure and occupation of the atomic orbitals. This is often measured as ionization energy, or the energy required to strip one electron away completely to form a positive ion.
Likewise, atoms have different electronegativities. This is an indirect measure of the ability of an atom to bind an extra electron to form a negative ion.
When an atom with a low ionization energy (typically a metal, like Li) forms a chemical bond with a highly electronegative atom (typically a main group atom on the right side of the periodic table, like F), then the bonding electrons will tend to spend more time around the electronegative atom, thereby lowering their energy and forming a stronger bond than if the electrons were equally shared by the two atoms.
Although formal oxidation states are useful concepts and we often indicate complete electron transfer by writing formulas like