The octet rule is a chemical rule of thumb that reflects the theory that main-group elements tend to bond in such a way that each atom has eight electrons in its valence shell, giving it the same electron configuration as a noble gas. The valence shell is the outermost shell of an atom that contains electrons. The octet rule is only applicable to the main group elements, which include the s-block elements and the p-block elements (except hydrogen, helium, and lithium). The octet rule is based on the observation that the atoms of the main group elements have a tendency to participate in chemical bonding in such a way that each atom of the resulting molecule has eight electrons in the valence shell.
When discussing the octet rule, only the s and p electrons are involved, making it useful for the main group elements (elements not in the transition metal or inner-transition metal blocks); an octet in these atoms corresponds to an electron configuration ending with s2p6/Electronic_Structure_of_Atoms_and_Molecules/Electronic_Configurations/The_Octet_Rule). Achieving the octet rule can be obtained through either ionic or covalent bonds. In covalent bonds, atoms share electrons. In ionic bonds, atoms transfer electrons between each other. Generally, metals will lose electrons to achieve a valence shell of eight electrons. Non-metals tend to gain electrons to obtain eight electrons.
Exceptions to the octet rule include free radicals, which are ions, atoms, or molecules containing an unpaired valence electron. These species disobey the octet rule, but they are very unstable and tend to spontaneously dimerize. Some stable molecular radicals obtain octet configurations by means of a three-electron bond which contributes one shared and one unshared electron to the octet of each bonded atom. Another exception is electron-deficient molecules such as boranes, which do not obey the octet rule but share delocalized electrons in a manner similar to metallic bonding.