Compounds

Compounds are substances containing atoms of more than one element in a fixed ratio. Many compounds can be classed as either ionic or molecular.

Molecular compounds exist as discrete groups of atoms having no overall charge. 
Two hydrogen atoms are linked by chemical bonds to an oxygen atom in the water molecule.
The bonds between atoms in molecules are covalent. This type of attractive force is due to the bonded atoms sharing one or more electron pairs.
Molecules can also be represented by a molecular formula that shows the symbols for the atoms in the molecule, with the number of each type given as a subscript.  H2O is the molecular formula for water.

Compounds containing only nonmetallic elements are nearly always molecular.

Ionic compounds exist as a lattice of positively and negatively charged ions.  A small portion of a lattice is shown below.
Ions are charged due to having unequal numbers of protons and electrons
Ionic compounds have no overall charge because the number of positive and negative charges in the lattice are equal.
A portion of the sodium chloride lattice is shown. 

Roll your mouse over the structure to see that each ion is surrounded by ions of opposite charge (Touch screen users should tap the image lightly.)

The bonds in an ionic compound are classed as ionic and are due to the attraction between the positive and negative ions.

The formula of an ionic compound shows the relative numbers of the two types of ions in the lattice.  The formula for the compound having the lattice shown above is NaCl because there is one Na+ for every Cl.

Compounds containing both metallic and nonmetallic elements are nearly always ionic.