Link selectors
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.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 65 | 79 | 50 | 9 | 65 | 9 | |
not match link `:any-link` privacy: selector does not match `<link>` elements | 65 | 79 | 87 | 15 | 65 | 15 |
| Other | ||||||
| `:link` | 1 | 12 | 1 | 1 | 18 | 3.2 |
| CSS selector | ||||||
not match link `:link` privacy: selector does not match `<link>` elements | 1 | 12 | 87 | 15 | 18 | 15 |
| Other | ||||||
| `:visited` | 1 | 12 | 1 | 1 | 18 | 1 |
| CSS selector | ||||||
not match link `:visited` privacy: selector does not match `<link>` elements | 1 | 12 | 87 | 15 | 18 | 15 |
privacy measures Restrict CSS properties allowed in a statement using `:visited` for privacy | 6 | 12 | 4 | 5 | 18 | 4.2 |
1+Supported (version) Not supported ※Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Notes 1 item(s)
Compatibility
- Available with a vendor prefix: -webkit- (1)
Notes 1 item(s)
Compatibility
- Available with a vendor prefix: -webkit- (79)
Notes 2 item(s)
Removed
- This feature was removed in a later browser version (50)
Compatibility
- Available with a vendor prefix: -moz- (1)
Notes 3 item(s)
Compatibility
- Available with a vendor prefix: -webkit- (3)
- Available with a vendor prefix: -khtml- (1.2)
Removed
- This feature was removed in a later browser version (3)
Notes 1 item(s)
Compatibility
- Available with a vendor prefix: -webkit- (18)
Notes 1 item(s)
Compatibility
- Available with a vendor prefix: -webkit- (1)
Syntax
CSS
:any-link {
color: #0066cc;
}
:visited {
color: #551a8b;
}
:link {
text-decoration: underline;
} Live demo
Use cases
-
Using Link selectors
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.
Cautions
- May not be supported in older browsers.
Accessibility
- Make sure visual changes are conveyed appropriately to assistive technology.