By · Updated

Link Underline Animation

Slide, Grow, Sweep and Highlight Hover Underlines for Links

No ratings yet

OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.

How the Link Underline Animation works

This link underline animation generator draws a line under a link that animates in when you hover or tab to it. Choose a slide, a grow from the centre, a sweep that exits the other side or a highlighter stroke, then copy the HTML and CSS.

An animated underline makes links feel responsive without changing the layout, and it works on any text length because the line is sized to the link itself.

How the link underline animation works

The line is an ::after layer stretched across the bottom of the link and squashed to zero width with transform: scaleX(0). On hover and keyboard focus it scales to full width. The transform-origin decides where it grows from, and Slide through swaps the origin on hover so the line leaves from the opposite side.

Highlighter style

The highlighter makes the layer taller and puts it behind the text with z-index: -1, so it looks like a marker pen stroke across the lower half of the words. Use a light colour so the text stays readable.

FAQ

Does the underline work on links that wrap onto two lines?

Only the last line gets the line, because the layer is positioned against the whole inline box. For multi-line links, animating background-size on a linear gradient underline is the usual alternative.

Is the animated underline accessible?

Yes. The same rule runs on :focus-visible, so keyboard users see the line when they tab to the link. Keep a static underline or other cue on body text links so they are recognisable before hover.

How do I use it on all links on my site?

Rename the .ul-link class in the copied CSS to a selector such as nav a, or add the class to each link. The rules only need the link to be positioned relatively.

See also: all Shadows & Motion tools, Layout & Spacing, Shapes & SVG, UI Components, Forms & Inputs, Colour.

Related tools