A detergent is a surfactant or a mixture of surfactants with cleansing properties in dilute solutions. These substances are usually alkylbenzenesulfonates, a family of compounds that are similar to soap but are more soluble in hard water, because the polar sulfonate (of detergents) is less likely than the polar carboxylate (of soap) to bind to calcium and other ions found in hard water.
In house contexts, the term detergent by itself refers specifically to laundry detergent or dish detergent, as opposed to hand soap or other types of cleaning agents. Detergents are commonly available as powders or concentrated solutions. Detergents, like soaps, work because they are amphiphilic: partly hydrophilic (polar) and partly hydrophobic (non-polar). Their dual nature facilitates the mixture of hydrophobic compounds (like oil and grease) with water. Because air is not hydrophilic, detergents are also foaming agents to varying degrees.