CSS :any-link Pseudo-class

Definition and Usage

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

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

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

Example

Example 1

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

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

Try It Yourself

Example 2

Set styles for all <a> elements that have the href attribute. In addition, 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 Link

Tutorial:CSS Button

Tutorial:CSS Pseudo-class