Bacterial pili assembled by the chaperone-usher pathway can mediate microbial attachment, an early step in the establishment of an infection, by binding specifically to sugars present in host tissues. Recent work has begun to reveal the structural basis both of chaperone function in the biogenesis of these pili and of bacterial attachment.