Electronegativity is a measure of how strongly an atom in a bond attracts the shared pair of electrons. The values most widely used are on the Pauling scale, where fluorine, the most electronegative element, has a value of 4.0.
Electronegativity increases across a period, because the nuclear charge grows while the outer electrons stay in the same shell. It decreases down a group, because the outer electrons are further from the nucleus and more shielded by the inner shells.
Fluorine, oxygen, nitrogen and chlorine have high values, while the alkali metals have the lowest. Helium, neon and argon are left out, as they form no stable compounds.
In a hydrogen molecule, \mathrm{H_2}, the two atoms are the same, so they share the electron pair equally. In hydrogen chloride, \mathrm{HCl}, chlorine (3.2) is more electronegative than hydrogen (2.2), so the shared pair is pulled towards the chlorine atom.
The chlorine end of the molecule gains a small negative charge, written δ-, and the hydrogen end is left with a small positive charge, written δ+. These partial charges are smaller than the charges of ions, because the electrons are still shared.
A covalent bond with partial charges is called a polar bond. The larger the difference in electronegativity between the two atoms, the more polar the bond.
Bonds can be placed along a scale by the difference in electronegativity between their atoms. In \mathrm{H_2} the difference is 0 and the bond is non-polar, while in \mathrm{HCl} it is 1.0 and the bond is polar.
In sodium chloride, \mathrm{NaCl}, the difference is 2.3. Chlorine attracts electrons so much more strongly than sodium that the sodium atom effectively gives up its outer electron, and the ions \mathrm{Na^+} and \mathrm{Cl^-} are held together by ionic bonding.
There is no sharp line between polar covalent bonds and ionic bonds. As the difference grows, bonding changes gradually from equal sharing, through unequal sharing, to the transfer of electrons.
A molecule with polar bonds is not always polar itself. In carbon dioxide, each \mathrm{C{=}O} bond is polar, but the two bonds point in opposite directions, so their polarities cancel and the molecule as a whole is non-polar.
Methane is non-polar for the same reason. Each \mathrm{C{-}H} bond is slightly polar, but the four bonds point to the corners of a regular tetrahedron and their polarities cancel.
In water and ammonia the polarities do not cancel. Because of the bent shape of water and the pyramidal shape of ammonia, the bond polarities add up, giving the oxygen or nitrogen atom a partial negative charge, so both molecules are polar.
Polarity helps to explain which substances mix. Water and ethanol both consist of polar molecules that attract one another, so the two liquids mix in any proportion.
Iodine, \mathrm{I_2}, and hexane, \mathrm{C_6H_{14}}, are both non-polar. Iodine dissolves readily in hexane to give a violet solution, but only very slightly in water.
Hexane and water do not mix, and form two layers. Polar substances tend to dissolve in polar solvents and non-polar substances in non-polar solvents, a rule often summed up as like dissolves like.