Detergents contain sulfonate or sulfate groups in their hydrophilic heads, which are derivatives of sulfur. This sulfur-based ionic structure is a key chemical difference from traditional soaps, which use carboxylate groups. The presence of these sulfur-containing groups makes detergents more effective in hard water and gives them different cleaning properties compared to soaps.