Electronegativity is the tendency of an atom to attract bonding electrons towards itself. An atom's electronegativity is affected by both the number of protons in the nucleus and the distance at which its valence electrons reside from the charged nucleus.
The type of bond that forms between two atoms is largely determined by the difference in electronegativity. You can find the electronegativity of an element in the chart below.
Nonpolar covalent bonds: (difference in electronegativity < 0.4) Electrons are shared evenly between the atoms. Molecules containing only these types of bonds are considered nonpolar.
Polar covalent bonds: (difference in electronegativity between 0.4 - 1.7) One atom pulls more strongly on the electrons and are shared unevenly between the atoms. Molecules containing these bonds are possibly polar. For a molecule to be polar it must also have a molecular geometry that does not balance the electron density.
Ionic bonds: (difference in electronegativity > 1.7) Electrons are transfered from one atom to another. Compounds containing these types of bonds are considered ionic.
Polar molecules have an uneven distribution of electrons resulting from differences in electronegativity, and therefore have slightly positive and slightly negative points. However, just having polar bonds is not enough for a molecule to be polar. The molecule must not have a symmetrical electron distribution.
Let's look at CO2:
Carbon and oxygen have a difference in Electronegativity of: 3.44 -2.55 = 0.89
This makes the C-O bond a polar bond with the electrons being pulled toward Oxygen.
However the CO2 molecule is a nonpolar molecule because of the linear geometry. Both oxygens have the same electronegativity and pull on the electrons with equal strength in opposite directions. This cancels out the polarity of the bonds.