Perming, relaxing, and coloring are the harshest things you can do to your hair from a chemist's viewpoint. But shampoos and conditioners also take advantage of chemistry to get their work done.
The job of shampoo is to clean the hair, so it's not surprising that the main ingredient in nearly all shampoos is detergent. Detergents create an anionic, or negatively charged, solution when combined with water. Such a formula is good for cleaning hair by attracting positively charged ions, such as oil. But it also tends to ruffle hair's outer cuticle, explaining why just-washed hair is often flyaway, unmanageable, and rather dull.
To counteract these undesirable effects and smooth down the hair cuticle, people often follow a shampoo with a rinse of a cationic, or positively charged, solution. In years past, people used vinegar, lemon juice, or beer for this purpose. Such rinses made hair glossier and easier to comb, but they could leave hair smelling like a tossed salad or a brewery. Modern conditioners achieve the same results and also have a pleasant fragrance more appropriate for hair.
One of the most important classes of conditioning agents is the quaternary ammonium compounds. These cationic substances help counteract static electricity and flyaway hair by binding to the anionic strands of shampooed hair. Because hair that has been permed, relaxed, or colored is considerably more anionic than normal hair, manufacturers design special conditioners packed with cationic ingredients for hair that has undergone a strong chemical treatment. Some formulas can even temporarily repair or strengthen chemically processed hair through the use of cationic proteins that cling to the hair's weakened keratin chains through hydrogen bonds.