Q: How do soaps and detergents work? What is the difference between the two?
A: Both soaps and detergents are long-chain hydrophobic (oily) molecules that have a hydrophilic (water-loving) segment on one end. When dissolved in water, these molecules clump together into spherical groupings called micelles, with the oily part of the molecules in the center and the water-loving portions on the surface. Dirt, which is mostly organic, dissolves in the oily center. The hydrophilic surface keeps it suspended in the water.
Soaps, which are generally made from natural products, have an ionic (charged) group for their hydrophilic segment, generally a carboxylate ion. The problem with such soaps is that in hard water, they react with calcium and magnesium ions to form insoluble salts that precipitate out of the water. This is the floating "curd" that appears in sinks and bathtubs. Detergents have a hydrophilic group that is not ionic, so insoluble salts do not form.