CKTIS / CSS
:any-link — any hyperlink
The `:any-link` pseudo-class selects hyperlinks whether or not they have been visited. In HTML, it matches `a` and `area` elements with an `href` attribute.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
:any-link:any-link selects an element that is the source of a hyperlink, not its target. HTML’s matching rules for :link and :visited cover a and area elements with href, but not link elements. An href attribute on a link element does not by itself establish a hyperlink. An a element without href does not match.
The pseudo-class takes no arguments. It is equivalent to :is(:link, :visited): it covers both unvisited and visited links. Use it to style both states together.
In the example, only Link gets a blue outline. No href lacks href, while Target is the link destination, not its source. Removing href from the first element makes it stop matching.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>:any-link example</title>
<style>
:any-link {
outline: 2px solid blue;
}
</style>
<a href="#target">Link</a>
<a>No href</a>
<p id="target">Target</p>
</html>Result
Link → 2px solid blue outline No href → no outline Target → no outline
The example compares `a` elements with and without `href`. It does not include `area` or `link` elements.