:any-link

The :any-link CSS pseudo-class selector represents an element that acts as the source anchor of a hyperlink, independent of whether it has been visited. In other words, it matches every <a> or <area> element that has an href attribute. Thus, it matches all elements that match :link or :visited.

/* Selects any element that would be matched by :link or :visited */
:any-link {
  color: green;
}

Syntax

:any-link

Examples

HTML

<a href="https://example.com">External link</a><br>
<a href="#">Internal target link</a><br>
<a>Placeholder link (won't get styled)</a>

CSS

a:any-link {
  border: 1px solid blue;
  color: orange;
}

/* WebKit browsers */
a:-webkit-any-link {
  border: 1px solid blue;
  color: orange;
}

Result

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
:any-link
65
1
79
79
50
1-50
No
52
15
9
3
1.2-3
65
≤37
65
18
50
4-50
47
14
9
1
9.0
1.0
not_match_link
65
79
87
No
52
No
Safari currently matches <link> elements with link pseudo-classes. See Bug: 220740.
65
65
87
47
No
Safari currently matches <link> elements with link pseudo-classes. See Bug: 220740.
9.0

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/:any-link