# Gradient Underline Link

> A link with a thin gradient underline that grows into a full highlight on hover, even across lines.

- Category: [CSS Text Effects](https://copy-css.com/category/text)
- Tags: link, hover, background-size, fill, multi-line
- Live preview: https://copy-css.com/snippets/gradient-underline-link
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<p class="link-grad-text">Read our <a class="link-grad" href="#">guide to accessible color</a> before you ship.</p>
```

## CSS

```css
.link-grad-text {
  max-width: 15em;
  margin: 0;
  color: #334155;
  font: 500 20px/1.6 system-ui, sans-serif;
}

.link-grad {
  padding: 0 0.1em;
  color: #312e81;
  font-weight: 700;
  text-decoration: none;
  background: linear-gradient(90deg, #4f46e5, #db2777) no-repeat left bottom / 100% 3px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-size 0.3s ease, color 0.3s ease;
}

.link-grad:hover,
.link-grad:focus-visible {
  background-size: 100% 100%;
  color: #ffffff;
}

.link-grad:focus-visible {
  outline: 2px solid #312e81;
  outline-offset: 2px;
}
```

## Notes

- This CSS Gradient Underline Link is 28 lines of pure CSS (0.6 KB) with no JavaScript and no dependencies. It uses transitions, linear gradients and keyboard focus styles.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
