Valency or valence refers to an atom's ability to accept or donate a pair of electrons to form a chemical compound.
The valency of noble gases or inert gases is zero since there are no free electrons in the valence shell, and the elements are already in a stable state.
The outermost shell of a hydrogen atom contains one electron. One more electron must be added to the outermost shell to achieve a stable state. Since hydrogen accepts only one electron, we decided that its valency is one. It sometimes shares electrons with the element of other atoms.
The oxygen atom has \(8\) electrons; hence, the electronic configuration is (\(2, 6\)). So, there are six electrons in the outermost shell. Two electrons are needed to complete the octet (\(2, 8\)). Thus, the valency of oxygen is \(2\).
Similarly, the magnesium atom has \(12\) electrons, hence, the electronic configuration of magnesium is (\(2, 8, 2\)). There are two valence electrons in the outermost shell. For achieving the octet, it requires \(6\) electrons. It is impossible for an atom to give away \(6\) electrons.
Electron distribution in \(O\) and \(Mg\)
Then, how can Magnesium complete its octet?
We already know that an atom can lose electrons to achieve the octet. So, it is easy to donate \(2\) electrons to other atoms to achieve the octet. Hence, the valency of magnesium is \(2\).
Formation of a bond or compound or molecule:
Lets us consider the formation of \(NaCl\) molecule. We need one \(Na\) atom and one \(Cl\) atom to form the compound \(NaCl\).
Electrons present = \(11\)
Electronic configuration = (\(2, 8, 1\))
Electrons present = \(17\)
Electronic configuration = (\(2, 8, 7\))
Where sodium will donate \(1\) electron to the chlorine atom to complete their respective octets; in this way, the molecule sodium chloride (\(NaCl\)) will form.
Formation of sodium chloride molecule