The octet rule is a chemical rule of thumb that states that atoms of main-group elements tend to combine in such a way that each atom has eight electrons in its valence shell, giving it the same electronic configuration as a noble gas. The rule is especially applicable to carbon, nitrogen, oxygen, and the halogens, but also to metals such as sodium or magnesium.
The bonding in carbon dioxide (CO2): all atoms are surrounded by 8 electrons, fulfilling the octet rule.
An atom is the smallest unit of matter that defines the chemical elements. Every solid, liquid, gas, and plasma is made up of neutral or ionized atoms.