Episode 32 of 53
Styling Links
Learn how to create beautiful, accessible link styles with hover effects and transitions.
Styling links well is crucial for both aesthetics and usability. Let's go beyond default blue underlines.
Removing Default Styles
a {
color: inherit;
text-decoration: none;
}
Modern Link Styling
a {
color: #2563eb;
text-decoration: none;
position: relative;
transition: color 0.2s ease;
}
a:hover {
color: #1d4ed8;
}
/* Animated underline effect */
a::after {
content: '';
position: absolute;
bottom: -2px;
left: 0;
width: 0;
height: 2px;
background: #1d4ed8;
transition: width 0.3s ease;
}
a:hover::after {
width: 100%;
}
Button-Style Links
.btn-link {
display: inline-block;
padding: 0.75rem 1.5rem;
background: #3498db;
color: white;
border-radius: 6px;
text-decoration: none;
font-weight: 600;
transition: background 0.2s, transform 0.1s;
}
.btn-link:hover {
background: #2980b9;
transform: translateY(-1px);
}
.btn-link:active {
transform: translateY(0);
}
Accessibility
- Links should be visually distinct from regular text
- Don't rely only on color — add underlines or other indicators
- Always include a
:focusstyle for keyboard users