:any-link
Matches both :link and :visited pseudo-classes. Selects any hyperlink regardless of visited state.
Quick example
:any-link { color: blue; }
:any-link:visited { color: purple; } Examples
Style all links the same, visited or not
a:any-link {
color: blue;
text-decoration: underline;
}
/* Both unvisited and visited links are blue */ Use :any-link to style links without caring about visit history, simpler than :link and :visited together.
Add hover effects to all links
a:any-link:hover {
text-decoration: none;
background-color: #e0e0e0;
} Combine :any-link with :hover to create consistent interactive states for all links.
Distinguish links from regular text
.article a:any-link {
font-weight: bold;
}
/* All links in articles are bold, regardless of visit status */ Style links within specific contexts without repeating selectors for :visited variants.
:any-link Browser Support
This feature is well established and works across many devices and browser versions. It has been available across browsers since 2020.
Safe to use without fallbacks.
Common pitfalls
While :any-link matches both visited and unvisited links, you cannot style visited links differently when using :any-link. Use :link and :visited separately if you need different colors for visited links.
Security restrictions prevent styling visited links with properties like background-color or borders. Only color and text-decoration work in :visited rules.