Putting magnesium and bromine together
Suppose you want to know the formula, or composition, of the compound that results from reacting magnesium with bromine. You start by putting the two atoms side by side, with the metal on the left, and then adding their charges. The following figure shows this process.Magnesium, an alkaline earth metal, has two valence electrons that it loses to form a cation with a 2+ charge. The electron configuration for the magnesium cation is:
Bromine, a halogen, has seven valence electrons, so it gains one to complete its octet (eight valence electrons) and form the bromide anion with a 1 charge. The electron configuration for the bromide anion is
The compound must be neutral; it must have the same number of positive and negative charges so that, overall, it has a zero charge. The magnesium ion has a 2+, so it requires 2 bromide anions, each with a single negative charge, to balance the 2 positive charges of magnesium. So the formula of the compound that results from reacting magnesium with bromine is:
Using the crisscross rule
There’s a quick way to determine the formula of an ionic compound: Use the crisscross rule.
Look at the preceding figure for an example of using this rule:
Take the numerical value of the metal ion’s superscript (forget about the charge symbol) and move it to the bottom righthand side of the nonmetal’s symbol — as a subscript.

Then take the numerical value of the nonmetal’s superscript and make it the subscript of the metal.
Note that if the numerical value is 1, it’s just understood and not shown.
So what happens if you react aluminum and oxygen? The figure below shows the crisscross rule used for this reaction.
Notice that because two ammonium ions (two positive charges) are needed to neutralize the two negative charges of the sulfide ion, the ammonium ion is enclosed in parentheses and a subscript 2 is added.
The crisscross rule works very well, but there’s a situation where you have to be careful. Suppose that you want to write the compound formed when magnesium reacts with oxygen. Magnesium, an alkaline earth metal, forms a 2+ cation, and oxygen forms a 2 anion. So you might predict that the formula is:
But this formula is incorrect. After you use the crisscross rule, you need to reduce all the subscripts by a common factor, if possible. In this case, you divide each subscript by 2 and get the correct formula:
MgO