• Skip to primary navigation
  • Skip to main content
  • Skip to footer
Web Design KC's Logo

Web Design KC

we build really cool websites for small businesses.

  • Home
  • Pricing
    • SEO
    • Maintenance Request
  • Portfolio
    • Case Studies
  • About
    • For Agencies
    • Locations
  • Blog
  • Contact
Home » Blog » Create an Animated Link Underline with CSS

Create an Animated Link Underline with CSS

November 2, 2026 by Kolten Craft Leave a Comment

CSS Lab 10 / Animated link underline — illustrated example

A short underline that extends when a link receives attention can give navigation a little personality. Use a pseudo-element so you can control the line’s thickness, position, and direction separately from the text. This pattern is designed for short standalone links, not every link on a page.

Try the CSS10 / Animated link underline

Change the CSS below. The preview updates as you type. Your edits stay in this browser tab.

Live preview

Hover or Tab to the links. Try another transform-origin and underline color.

HTML for this example
<nav class="underline-demo" aria-label="Example navigation"><a href="#underline-note">Explore our work</a><a href="#underline-note">Meet the studio</a></nav><p id="underline-note" class="example-note">Demo links. Keep ordinary underlines on links inside paragraphs.</p>

Scale the line from one side

The ::after layer spans the link’s width. It starts at scaleX(.18), leaving a small visible cue, and grows to full width on hover or keyboard focus. transform-origin: left anchors that growth. Try center for a line that expands in both directions, or right for the opposite emphasis.

Keep the focus indicator distinct

An animated line can be subtle, so keyboard focus also gets a clear outline. Touch devices show the complete underline without waiting for a hover state. Reduced-motion preferences keep the state change but remove its transition. Change --line only after checking that the indicator remains visible against the background.

Choose the right place to use it

This single pseudo-element draws one line beneath the link box. It does not follow every line of a wrapped paragraph link. Keep native text underlines for body copy, and test longer navigation labels at phone widths and increased text sizes. If a label wraps awkwardly, simplify the treatment rather than forcing the text into a fixed-width box.

Reference: MDN on transform-origin.

Have a client website that needs this kind of attention? See our WordPress development for agencies and case studies.

Keep exploring

CSS LabAccessibilityAnimation
  • Navigation Design: Guiding the Clicks (Not Losing the Visitor) ↗
  • Zoom an Image Inside Its Frame on Hover with CSS ↗
  • Create a Button with a Sliding CSS Background ↗

Browse the full blog →

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Footer

phone – (816)694-0458
email – kolten@webdesignkc.com

copyright © 2026

WebDesignKC-Logo-Teel

let’s work together on
your next project!

contact

Copyright © 2026 • WebDesignKC • Design by Web Design KC Logo