# Underline Nav Links

> Header navigation links with an underline that grows in on hover and marks the active page.

- Category: [CSS Navigation](https://copy-css.com/category/navigation)
- Tags: nav, links, underline, active, header
- Live preview: https://copy-css.com/snippets/underline-nav
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<nav class="nav-links">
  <a href="#" aria-current="page">Home</a>
  <a href="#">Pricing</a>
  <a href="#">Blog</a>
</nav>
```

## CSS

```css
.nav-links {
  display: flex;
  gap: 22px;
  font: 600 16px system-ui, sans-serif;
}

.nav-links a {
  position: relative;
  padding: 6px 0;
  color: #64748b;
  text-decoration: none;
  transition: color 0.2s ease;
}

.nav-links a::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  border-radius: 2px;
  background: #6366f1;
  transform: scaleX(0);
  transition: transform 0.25s ease;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: #111;
}

.nav-links a:hover::after,
.nav-links a[aria-current="page"]::after {
  transform: scaleX(1);
}
```

## Notes

- This CSS Underline Nav Links is 36 lines of pure CSS (0.6 KB) with no JavaScript and no dependencies. It uses transitions, transforms and Flexbox.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
