Movatterモバイル変換


[0]ホーム

URL:


  1. 面向开发者的 Web 技术
  2. CSS:层叠样式表
  3. CSS 参考
  4. 选择器
  5. :any-link

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in EnglishAlways switch to English

: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 2020年1月.

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

尝试一下

p {  font-weight: bold;}a:any-link {  color: forestgreen;  text-decoration-color: hotpink;}
<p>Pages that you might have visited:</p><ul>  <li>    <a href="https://developer.mozilla.org">MDN Web Docs</a>  </li>  <li>    <a href="https://www.youtube.com/YouTube">Google</a>  </li></ul><p>Pages unlikely to be in your history:</p><ul>  <li>    <a href="https://developer.mozilla.org/missing-3">Random MDN page</a>  </li>  <li>    <a href="https://example.com/missing-3">Random Example page</a>  </li></ul>

语法

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

浏览器兼容性

参见

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp