CSS :any-link pseudo-class

Definition and usage

CSS :any-link Pseudo-classes are used to select and set the styles of elements that act as anchor points for hyperlinks.

This pseudo-class works regardless of whether the link has been visited or not.

Therefore, this pseudo-class applies to all elements with the href attribute <a> or <area> Element.

Example

Example 1

Select and set the styles for all <a> elements with the href attribute:

a:any-link {
  background-color: yellow;
  color: maroon;
}

Try it yourself

Example 2

Set styles for all <a> elements with the href attribute. Additionally, set link styles based on the state (hover, active, visited, 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

CSS syntax

:any-link {
  css declarations;
}

Technical details

Version: CSS Selectors Level 4

Browser support

The numbers in the table indicate the first browser version that fully supports this pseudo-class.

Chrome Edge Firefox Safari Opera
65 79 50 9 52

Related pages

Tutorial:CSS link

Tutorial:CSS button

Tutorial:CSS pseudo-class