Soap does not lather well in hard water. The hardness of water is due to dissolved calcium and magnesium salts in it. These salts react with soap to form insoluble compounds resulting in the decrease of lather. But detergents do not give insoluble components on reaction with these salts. Hence detergents are more effective than soaps in hard water.