Differential media work by incorporating indicators that produce visible changes when specific metabolic reactions occur. For instance, a common differential medium like MacConkey agar contains lactose and a pH indicator. Bacteria that can ferment lactose produce acid, lowering the pH and changing the color of the medium. This helps distinguish lactose-fermenting bacteria such as Escherichia coli from non-fermenters like Salmonella.