:any-link
Widely availableSince 202097% of users
Matches both :link and :visited pseudo-classes. Selects any hyperlink regardless of visited state.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyModernIn every major browser since January 2020. Widely available since July 2022.
Newer parts of :any-link
:any-link privacy: selector does not match <link> elementsBaseline Sept 2021, Widely Mar 2024
See how modern your own CSS is.Check your CSS →
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.
Common pitfalls
- :any-link ignores :visited stylingWhile :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.
- Limited CSS properties in :visitedSecurity restrictions prevent styling visited links with properties like background-color or borders. Only color and text-decoration work in :visited rules.
:any-link browser support
BaselineWidely availableThis 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.
Usage97%of people can use this3% use a browser without it.
Browsers
65+
50+
9+
79+Mobile
65+Android
50+Android
9+iOS