A CSS-only animated underline that handles wrapping text

Nicky Meuleman has described how the anchor link hover effect on their sites was built, an effect they credit to inspiration from Cassie Evans. On hover, a second underline in a different color slides in, leaving a gap between it and the original underline.

Because standard text-decoration can't produce that behavior, the effect is implemented with multiple backgrounds instead. A useful property of this approach is that it also works when the linked text wraps across more than one line.

Source

Meuleman's write-up is available direct: CSS animated wrapping underline.