Soaps and detergents are cleansing agents that use their molecular structure to dissolve dirt and grease. Soaps have a hydrophilic ionic group that dissolves in water and a hydrophobic hydrocarbon tail that attaches to non-polar particles. Detergents are similar but contain sulfonate groups, which allow them to work effectively in hard water by forming soluble salts with calcium and magnesium ions. Both soaps and detergents use micelle formation and emulsification to suspend dirt and oil in water so they can be rinsed away.