About this snippet

Discover how to create an elegant CSS link effect where an underline smoothly grows on hover. This modern styling enhances user interaction without JavaScript, perfect for clean website designs.

Size
935 bytes
Uses
HTML, CSS
Loads
Nothing external
Views
390
<div class="link-container">
  <a href="#" class="link-style-modern-1">Hover Me</a>
</div>
/* Basic body styling for demonstration */
body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Arial', sans-serif;
  background-color: #f0f2f5;
  margin: 0;
}
.link-container {
  padding: 20px;
}

.link-style-modern-1 {
  position: relative;
  text-decoration: none;
  color: #3498db;
  font-size: 1.5rem;
  padding: 5px 0;
  transition: color 0.3s ease;
}

.link-style-modern-1::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: #2980b9;
  transition: width 0.3s ease-in-out;
}

.link-style-modern-1:hover,
.link-style-modern-1:focus {
  color: #2980b9;
  outline: none; /* For focus, custom focus styling is better if needed */
}

.link-style-modern-1:hover::after,
.link-style-modern-1:focus::after {
  width: 100%;
}
Esc
↑↓ moveEnter select

Start from a template

Open an .html file, or HTML, CSS, JS, Markdown, Less or TypeScript files. You can also drop them here. Styles and scripts go into their panes.

Share

Source

Keyboard shortcuts

Save