Detergents are generally ammonium or sulphonate salts of long chain carboxylic acids. The charged ends of these compounds do not form insoluble precipitate with calcium or magnesium ions. Calcium and magnesium ions are present in hard water. Due to this, detergents are effective even in hard water. Hence, detergents are better cleansing agents than soaps.