: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.
Bộ chọn :any-link lớp giả CSS đại diện cho một phần tử đóng vai trò là điểm neo nguồn của siêu liên kết, bất kể nó đã được truy cập hay chưa. Nói cách khác, nó khớp với mọi phần tử <a> hoặc <area> có thuộc tính href. Do đó, nó khớp với tất cả các phần tử khớp với :link hoặc :visited.
Try it
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://mdn.go-mizu.dev">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://mdn.go-mizu.dev/missing-3">Random MDN page</a>
</li>
<li>
<a href="https://example.com/missing-3">Random Example page</a>
</li>
</ul>
Cú pháp
css
:any-link {
/* ... */
}
Ví dụ
>HTML
html
<a href="https://example.com">External link</a><br />
<a href="#">Internal target link</a><br />
<a>Placeholder link (won't get styled)</a>
CSS
css
a:any-link {
border: 1px solid blue;
color: orange;
}
/* WebKit browsers */
a:-webkit-any-link {
border: 1px solid blue;
color: orange;
}
Kết quả
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Selectors Level 4> # the-any-link-pseudo> |