
CSS Animated Underline on Hover
Published
26 hand-coded CSS link and text hover effects — animated underlines, gradient text with background-clip, border-draw traces, slide-in fills, liquid text fill, glowing halos, wavy squiggles, character morphs, dotted focus rings, arrow slides, terminal cursors, neon flickers, heartbeat pulses, sweep reveals, letter push staggers, marker highlighters, background slides, crosshair brackets, glitch splits, ink bleeds, magnetic cursor pulls, brutalist shadows, 3D text flips, and typewriter type-on reveals. Every demo pairs :hover with :focus-visible so keyboard users get the same feedback as mouse users, and every animation uses GPU-composited transform or opacity for zero CLS + zero INP. Scoped under .cle-NN for no-collision pasting, prefers-reduced-motion guarded, framework-agnostic.
Related30 CSS Hover Effects30 CSS Text Animations15 CSS Navigation Menu Designs

Published

Published

Published

Published

Published

Published

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

PublishedUpdated

Published
position: relative and remove the browser underline; on the ::after pseudo-element set position: absolute, pin it flush to the bottom edge, give it width: 100%; height: 2px; background: currentColor, then start it collapsed with transform: scaleX(0) and transform-origin: left. On hover and focus-visible, animate to transform: scaleX(1) using a 220ms cubic-bezier(0.4, 0, 0.2, 1) transition. Why scaleX beats width: transform is GPU-composited (zero layout, zero paint, zero CLS), while width triggers layout + paint on every frame at 60fps. The transform-origin: left makes the underline grow left-to-right; swap to right for right-to-left, or center for center-out (Demo 07's squiggly variant does this). Include focus-visible so keyboard users get the same feedback — WCAG 2.4.7 requires it and WCAG 2.4.13 (October 2023) added the 2px minimum thickness + 3:1 contrast rule the browser default fails. On mobile, wrap the whole rule in @media (hover: hover) and (pointer: fine) so touch users don't see a stuck-on state after a tap.background-clip: text plus color: transparent to reveal a gradient through the letter shapes. Full recipe: give the anchor a linear-gradient(90deg, ...) background across your brand hues, add background-size: 100% 100%, then set -webkit-background-clip: text; background-clip: text; color: transparent and transition background-position on hover. The -webkit- prefix is still required for Safari 15.4 and older (real-world tier-1 mobile Safari share is ~4% at that version as of 2026). For the sliding-gradient variation, set background-size: 200% 100% and animate background-position from 0% 0% to -100% 0%. For the animated hue-rotation variation, use @property --hue (Baseline 2024, Chrome 85+ / Safari 16.4+ / Firefox 128+) with a typed angle and animate the hue value directly — this is how Stripe's homepage headline animates its rainbow gradient without triggering re-paints. Fallback for pre-2024 browsers: static gradient at rest, no animation on hover. This is the exact pattern shipped by Stripe's marketing homepage, Vercel's product tour, Linear's launch page, Framer's landing headlines, and every other tier-1 SaaS with a gradient-heavy brand system.position: relative, then generate two pseudo-elements plus two nested spans for the four sides. Each segment is position: absolute; background: currentColor; transition: 250ms ease-out. The top segment starts flush to top-left at width: 0; height: 2px and animates width to 100%. The right segment starts flush to top-right at width: 2px; height: 0 and animates height to 100%. Stagger the transition-delay: top 0ms, right 250ms, bottom 500ms, left 750ms — total draw about 1s. For a modern one-element alternative, use a single border with mask-composite: exclude plus a mask-image: conic-gradient(...) animating the conic angle via @property --angle (Baseline 2024) — the whole border traces from one corner. On tier-1 portfolio and creative-agency traffic (queries like 'css line drawing box hover', 'css border trace animation'), this pattern lands on Awwwards-adjacent sites where the visual signature IS the value prop.a:hover, a:focus-visible { ... } on every rule, never a:hover alone. (2) The focus-visible outline must be at least 2px thick with at least 3:1 contrast against BOTH the link background and any adjacent surface (WCAG 2.4.13, added October 2023) — a 1px hairline outline that used to pass now fails. (3) Every animation (glow pulse, squiggle scroll, letter push stagger, neon flicker) must be wrapped in @media (prefers-reduced-motion: reduce) and either drop to instant final state or kill the animation entirely. WCAG 2.3.3 requires this, and iOS + macOS + Android + Windows all expose the OS-level reduce-motion toggle these days — real users flip it. Never rely on color alone to signal the link (WCAG 1.4.1 Use of Color) — a color-shift hover fails for anyone with red-green colorblindness (~8% of male visitors in tier-1 markets). Combine color with underline, weight, or the animation itself. This meets Section 508 refresh (36 CFR 1194), UK EN 301 549 for public-sector procurement, Australia's Disability Discrimination Act 1992 via the Digital Service Standard, and Canada's Accessible Canada Act 2019 — the exact standards enterprise buyers cite when evaluating a marketing site's a11y.transform or opacity (GPU-composited, no layout thrash) instead of width / height / top / left (which would trigger reflow). The one exception to watch: filter: blur() on the glow demos (Demo 06 glowing text, Demo 13 neon sign flicker) does trigger a filter compositing layer, which adds 4-12ms to INP on lower-end Android devices (Snapdragon 4 Gen 2 class). We ship a @media (max-width: 480px) fallback that swaps filter: blur() for a static text-shadow on those mobile viewports, keeping INP under 100ms on every device. On tier-1 SEO for the 'css link hover effects', 'css animated underline', 'css gradient text hover' query cluster, the CWV score directly compounds against the Google Ads Quality Score — a page with 'Good' CWV pays 20-40% less per click for the same ad placement, so shipping GPU-composited hover animations pays for itself on both organic ranking AND ad-revenue economics..cle-NN CSS block straight into React (rename class to className), Vue (SFC accepts as-is), Svelte or SvelteKit (accepts class natively), Astro (as an .astro component or via a global stylesheet), Next.js App Router (any server or client component — no 'use client' needed for these zero-JS effects), Remix (any route module), or Solid.js. All 26 demos are MIT licensed and free for commercial use. Compared to premium alternatives: Tailwind's arbitrary-value pseudo-classes express the same rules with more bracket noise and don't ship the exotic effects (border-draw, neon flicker, glitch, magnetic pull) as first-class utilities; shadcn's Link primitive is 0 USD but ships only the underline pattern; Framer Motion's whileHover needs the 60KB library for what CSS handles in 8 lines. The hand-coded pattern here totals about 4-8KB gzipped for the whole 26-demo collection when you cherry-pick — a fraction of any framework's overhead. The .cle-NN numeric prefix means 26 demos coexist on one gallery page without collision, and the scoped naming means you can drop any one demo into a codebase that already uses .link or .nav-link classes without a rename.20 hand-coded CSS animated buttons — neon glow, ripple, 3D press, liquid fill, jelly bounce, shine sweep, animated border, moving gradient CTA, text flip, submit success state, add-to-cart progress, download icon, hamburger-to-close, toggle switch, loading spinner inside button, next/prev arrow nav, and ghost button background reveal. Half pure CSS, half lightweight JS for production interactions.
11 pure CSS animation-timeline demos built on the W3C scroll() and view() spec — reading progress bar, view-timeline fade & reveal, shrinking sticky header, stacking cards, horizontal scroll section, parallax hero, container shadow indicators, reverse-scroll columns, text scrim reveal, cover card to sticky header, and image zoom / clip-path wipe. Zero JS, off the main thread, Core Web Vitals safe. Copy-paste ready.
25 hand-coded CSS background animations for SaaS hero sections, developer tool documentation, agency portfolios, gaming and Web3 landing pages, seasonal e-commerce campaigns, and dark-mode dashboards. Covers full-screen gradient shifts, animated mesh gradients, aurora borealis glow, cursor spotlight follow, interactive water ripples, dot grid and diagonal stripe patterns, SVG grain and noise texture overlays, topographic contour lines, layered SVG waves, plasma and lava lamp fluids, bokeh light blur, particle constellation networks, matrix digital rain, synthwave 3D perspective grids, starfield warp speed, CRT scanline overlays, fog and mist drift, morphing organic blobs, floating glassmorphism orbs, halftone dot patterns, starry night skies, floating geometric shapes, rising bubbles, and falling snow. 20 are pure CSS with zero JavaScript; the 5 that need it use vanilla canvas or pointer tracking with no dependencies. Every background animates compositor-only properties so it never blocks the main thread, is scoped under a .bga-NN prefix for no-collision pasting, guards prefers-reduced-motion, and ports unchanged to React, Vue, Svelte, Astro, Next.js and Tailwind.