Detergent decreases the surface tension of water and attracts molecules of dirt and grease. The surface-active elements that make up detergent have two ends. The hydrophilic (water-loving) end attracts water and pulls it towards the hydrophobic (water-hating) end. This reduces the surface tension of the water while also drawing the grease into the water. The combination is then suspended in mid-air on top of the clothing and washed off.
Surfactants are also effective as emulsifiers, dispersants and foaming agents. As emulsifiers, they encourage the mixing of normally insoluble substances, such as water and oil, by suspending particles of one in the other. As dispersants, they cause droplets of grease to break off the main source, which makes things easier to clean. As foaming agents, the hydrophilic end of the detergent molecule points away from the water and toward the air, which forms bubbles as it is rubbed into the water quickly.
Chemically, there are several different kinds of detergents. Anionic and cationic brands are preferred for their effectiveness in breaking down proteins, but they are also harsh on clothing. Non-ionic brands remove dirt without causing proteins to break down as easily. Zwitterionic detergents have characteristics of the ionic and non-ionic brands and are used in chemical laboratories instead of the average household.