Grow your CSS skills. Land your dream job.

Last updated on:

Gradient Underlines

a {
  position: relative;
  padding-bottom: 2px;
  text-decoration: none;

a:hover::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 0;
  height: 1px;
  width: 100%;
  background: #444;
  background: linear-gradient(left, transparent 0%,#444 50%,transparent 100%);

See the Pen Gradient Underlines by Chris Coyier (@chriscoyier) on CodePen.


  1. asd
    Permalink to comment#


  2. Nicklas
    Permalink to comment#

    Not bad!

    Throw some transition into that and it’ll be even fancy-er! :)

  3. Sarang
    Permalink to comment#

    Awesome Man ! Thanx Big Thanx !

  4. Brett M
    Permalink to comment#

    Is there a fix for line wrapping? When my link is long enough to wrap onto the next line, the next line won’t be underlined.

Leave a Comment

Posting Code

  • Use Markdown, and it will escape the code for you, like `<div class="cool">`.
  • Use triple-backticks for blocks of code.
      <h1>multi-line block of code</h1>
      <span>be cool yo.</span>
  • Otherwise, escape your code, like <code>&lt;div class="cool"&gt;</code>. Markdown is just easier though.

Current ye@r *

*May or may not contain any actual "CSS" or "Tricks".