CSS :any-link Pseudo-class
Example
Select and style all <a> elements with an href attribute:
a:any-link {
background-color: yellow;
color: maroon;
}
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The CSS :any-link
pseudo-class is used to select and style
an element that is acting as a source anchor of a hyperlink.
It does not matter if the link has been visited or not.
So, this pseudo-class applies to all <a> or <area> elements with an href attribute.
Version: | CSS Selectors Level 4 |
---|
Browser Support
The numbers in the table specifies the first browser version that fully supports the pseudo-class.
Pseudo-class | |||||
---|---|---|---|---|---|
:any-link | 65 | 79 | 50 | 9 | 52 |
CSS Syntax
:any-link {
css declarations;
}
More Examples
Example
Style all <a> elements with an href attribute. In addition, style the links based on state (hover, active, unvisited, etc):
a:any-link {
background-color: yellow;
color: maroon;
}
a.ex1:hover, a.ex1:active {
color: red;
}
a.ex2:hover, a.ex2:active {
font-size: 150%;
}
Try it Yourself »
Related Pages
CSS tutorial: CSS Links
CSS tutorial: CSS Buttons
CSS tutorial: CSS Pseudo classes