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 will work regardless of whether the link has been visited or not.

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

Example

Example 1

Select and set styles for all <a> elements that have an href attribute:

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

Try It Yourself

Example 2

Set styles for all <a> elements that have an 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 specify the first browser version that fully supports this pseudo-class.

Chrome Edge Firefox Safari Opera
65 79 50 9 52

Related Pages

Tutorial:CSS Links

Tutorial:CSS Buttons

Tutorial:CSS Pseudo-classes