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
.
On this page
:any-link
Try it
Syntax
css
:any-link {
/* ... */
}
Examples
HTML
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
css
a:any-link {
border: 1px solid blue;
color: orange;
}
/* WebKit browsers */
a:-webkit-any-link {
border: 1px solid blue;
color: orange;
}
Result
Specifications
Specification |
---|
Selectors Level 4 # the-any-link-pseudo |
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 |
651 | 7979 | 501–50 | No | 5215 | 931.2–3 | 65≤37 | 6518 | 504–50 | 4714 | 91 | 9.01.0 |
not_match_link |
65 | 79 | 87 | No | 52 | 65 | 65 | 87 | 47 | 9.0 |
See also
© 2005–2023 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