--- title: ':any-link' slug: 'Web/CSS/:any-link' tags: - CSS - 实验性 translation_of: 'Web/CSS/:any-link' ---
:any-link
CSS 伪类 选择器代表一个有链接锚点的元素,而不管它是否被访问过,也就是说,它会匹配每一个有 href
属性的 {{HTMLElement("a")}}、{{HTMLElement("area")}} 或 {{HTMLElement("link")}} 元素。因此,它会匹配到所有的 {{cssxref(":link")}} 或 {{cssxref(":visited")}}。
/* 选中任意匹配 :link 和 :visited 元素*/
:any-link { color: green; }
<a href="https://example.com">External link</a><br> <a href="#">Internal target link</a><br> <a>Placeholder link (won't get styled)</a>
a:any-link { border: 1px solid blue; color: orange; } /* WebKit browsers */ a:-webkit-any-link { border: 1px solid blue; color: orange; }
{{EmbedLiveSample('Example')}}
Specification | Status | Comment |
---|---|---|
{{SpecName("CSS4 Selectors", "#the-any-link-pseudo", ":any-link")}} | {{Spec2('CSS4 Selectors')}} | Initial definition. |
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
{{Compat("css.selectors.any-link")}}