Ionic formulas are determined by balancing positive (cation) and negative (anion) charges. The formula shows the simplest whole-number ratio of ions, with no net charge. Polyatomic ions are written as units. The cation is named first, followed by the anion. Understanding charge and valence is essential for writing correct formulas.
You already understand that ionic bonds form when a metal transfers electrons to a nonmetal, producing a positively charged cation and a negatively charged anion. Writing the formula for the resulting compound is essentially a charge-balancing exercise: the total positive charge must exactly cancel the total negative charge so that the compound is electrically neutral.
The procedure is straightforward. First, identify the charges on each ion. Sodium is Na⁺, chloride is Cl⁻ — one of each gives NaCl with zero net charge. But consider calcium (Ca²⁺) and chloride (Cl⁻): one calcium ion carries +2, so you need two chloride ions at −1 each to balance. The formula is CaCl₂. A useful shortcut is the criss-cross method: take the magnitude of each ion's charge and use it as the subscript for the other ion. For Al³⁺ and O²⁻, the 3 becomes oxygen's subscript and the 2 becomes aluminum's, giving Al₂O₃. Always reduce to the simplest whole-number ratio — Mg²⁺ and O²⁻ would criss-cross to Mg₂O₂, but that simplifies to MgO.
Polyatomic ions — groups like sulfate (SO₄²⁻), nitrate (NO₃⁻), or ammonium (NH₄⁺) — are treated as single units. When you need more than one of a polyatomic ion, enclose it in parentheses before adding the subscript. Calcium nitrate is Ca(NO₃)₂, not CaNO₃₂, because the subscript 2 applies to the entire NO₃⁻ unit. Forgetting the parentheses changes the meaning of the formula entirely.
Two conventions complete the picture. The cation is always written first in the formula, regardless of how the compound is named verbally — so it is Na₂SO₄, never SO₄Na₂. And ionic formulas represent the simplest ratio of ions in the crystal lattice, not a discrete molecule. NaCl does not mean one sodium atom is bonded to one chlorine atom in isolation; it means the ratio of sodium to chloride in the extended crystal is 1:1. This distinction between formula units and molecules matters when you move into stoichiometry and solution chemistry.