From Bowditch's American Practical Navigator:
Offshore, some shade of blue is common, particularly in tropical or subtropical regions. It is due to scattering of sunlight by minute particles suspended in the water, or by molecules of the water itself. Because of its short wavelength, blue light is more effectively scattered than light of longer waves. Thus, the ocean appears blue for the same reason that the sky does. The green color often seen near the coast is a mixture of the blue due to scattering of light and a stable soluble yellow pigment associated with phytoplankton. Brown or brownish-red water receives its color from large quantities of certain types of algae, microscopic plants in the sea, or from river runoff.