When two hydrogen atoms come close together, each atom provides its single electron, and the two electrons form a pair that both atoms share.
The shared pair is attracted by both nuclei, and this holds the two atoms together as a hydrogen molecule, \mathrm{H_2}. A bond formed by a shared pair of electrons is called a covalent bond.
Covalent bonds usually form between atoms of nonmetals.
A chlorine atom has 7 outer electrons. In a chlorine molecule, \mathrm{Cl_2}, the two atoms share one pair, and when the shared electrons are counted for both atoms, each atom has 8 outer electrons, like argon.
In a water molecule, the oxygen atom shares one pair with each of two hydrogen atoms. The oxygen atom then has 8 outer electrons, like neon, and each hydrogen atom has 2, like helium.
By sharing electrons, the atoms in a molecule usually end up with the same arrangement of electrons as a noble gas.
A Lewis structure shows the outer electrons of each atom as dots around its symbol.
A pair of electrons shared between two atoms is called a shared pair, or bonding pair, and a pair that belongs to only one atom is called a lone pair.
A water molecule has 2 shared pairs and 2 lone pairs, an ammonia molecule has 3 shared pairs and 1 lone pair, and a methane molecule has 4 shared pairs and no lone pair.
In a structural formula, each shared pair is drawn as a single line between two atoms.
The number of covalent bonds that an atom usually forms is called its valency: 1 for hydrogen, 2 for oxygen, 3 for nitrogen and 4 for carbon.
The valency equals the number of electrons the atom needs to reach the arrangement of a noble gas, so the structural formulas of water, ammonia and methane follow directly from it.
Two atoms can share more than one pair of electrons. Sharing two pairs makes a double bond, and sharing three pairs makes a triple bond.
There is a double bond between the oxygen atoms in \mathrm{O_2} and between the carbon atoms in ethene, \mathrm{C_2H_4}, and a carbon dioxide molecule has two double bonds.
There is a triple bond between the nitrogen atoms in \mathrm{N_2} and between the carbon atoms in ethyne, \mathrm{C_2H_2}. The more pairs two atoms share, the shorter and stronger the bond between them.