This is a question that always hinders us initially in our Chemistry class. All that talk of electrons, ions and valence shells has our head spinning! In reality, the concept is quite easy. For simplicity, let us make a broad classification and divide the chemical elements into two: metals and non-metals.
Let’s start by understanding what an ion is. Simply stated, an ion is an atom that is charged. Ions can be of two kinds: An-ion (- charge), and Cat-ion (+charge). When two atoms of different elements bond together, they have to come together as ions: one atom acts as the anion, and the other acts as the cation.
Now let’s talk about valence shells and valence electrons. We know that an atom consists of various shells, and electrons orbit in these shells. The outermost shell is called the valence shell, and the electrons present in it are the valence electrons. For example: Magnesium has 2 valence electrons, while Aluminum has 3.
Elements bond to attain greater stability. Normally this means a full valence shell of 8 electrons, also called an octet. Hence, to attain stability, metals can either gain electrons or lose them. In the case of metals, it is easier to lose electrons then gain them; Magnesium can lose 2 electrons more easily than gain 6. Having lost electrons, which are negatively charged, atoms of metals therefore gain a net positive charge i.e they become cations. On the other hand, just for the sake of understanding, Chlorine, a non-metal has 7 valence electrons. Cl atoms gain 1 electron, therefore making them anions.
All chemical reactions are driven to gain more stability. The process of metal atoms becoming cations is no different.