Cephalosporins work by inhibiting bacterial cell wall synthesis. They bind to penicillin-binding proteins (PBPs) located inside the bacterial cell wall, leading to the weakening and eventual lysis of the bacterial cell. This mechanism makes them effective against a wide range of bacterial species.