:any-link

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

:any-link CSS 伪类选择器表示作为超链接源锚点的元素,无论是否已被访问。换言之,它匹配每个具有 href 属性的 <a><area> 元素。因此,它匹配所有匹配 :link:visited 的元素。

尝试一下

语法

css
:any-link {
  /* ... */
}

示例

HTML

html
<a href="https://example.com">外部链接</a><br />
<a href="#">内部目标链接</a><br />
<a>占位符链接(不会有样式)</a>

CSS

css
a:any-link {
  border: 1px solid blue;
  color: orange;
}

/* WebKit 浏览器 */
a:-webkit-any-link {
  border: 1px solid blue;
  color: orange;
}

结果

规范

Specification
Selectors Level 4
# the-any-link-pseudo

浏览器兼容性

BCD tables only load in the browser

参见