Molecular Bonding
Atoms bond together by sharing electrons. Each of two atoms donates one of its electrons, and the resulting pair of electrons orbits around the two atoms, creating a bond. If the electrons are shared more or less equally between the two atoms, this is known as a covalent bond. When one of the two atoms has a greater attraction for electrons than the other, that atom can pull both electrons to itself, gaining an overall negative charge and leaving the other atom positive. This is known as an ionic bond.
Electronegativity
The ability of an atom to pull bonding electrons to itself is known as electronegativity. Each element has a degree of electronegativity, which varies according to the composition of its atoms. Electronegativity increases going from left to right along a row of the periodic table, as the elements gain more positive protons in their inner nucleus. Electronegativity decreases going down from top to bottom in the table, as the outer orbits of electrons around the atoms get further from the nucleus.
Degrees of Polarity
When two atoms bond, the extent to which one atom takes the two bonding electrons is determined by the difference in electronegativity between them. If the difference is significant, one atom will take a greater share of the electrons. This can result in bonds that are part way between purely covalent and purely ionic. Such compounds exhibit polarity, meaning that one atom takes on a partial negative charge and one a partial positive charge.
Polar and Nonpolar
Chemists measure the degree of polarization of a bond in percent ionic character, and you can determine this value from the difference in electronegativity of two atoms. For example, water contains the bond O-H between oxygen and hydrogen. The electronegativity of O is 3.5 and H is 2.1, so they differ by 1.4. On a chart of ionic character, you will find this bond is 39 percent ionic, thus a compound containing O-H will be quite polar. The ionic character of a carbon-hydrogen bond is only 4 percent, so a compound containing only C-H would be nonpolar. (ref 1 and 2)