blob: b6d515c4f07564f9c8ebeba55ecdd1a54ae163ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
---
title: ':any-link'
slug: Web/CSS/:any-link
tags:
- CSS
- Experimental
- Pseudo-classe
- Reference
translation_of: Web/CSS/:any-link
---
{{CSSRef}}
La pseudo-classe **`:any-link`** permet de représenter un élément qui agit comme la source de l'ancre d'un hyperlien (qu'il ait été visité ou non). Elle permet donc de cibler les éléments {{HTMLElement("a")}}, {{HTMLElement("area")}} ou {{HTMLElement("link")}} avec un attribut `href`. Autrement dit, elle cible les éléments qui correspondent à {{cssxref(":link")}} ou à {{cssxref(":visited")}}.
```css
/* cible tous les éléments qui seraient ciblés par */
/* :link ou :visited */
:any-link {
color: green;
font-weight: bold;
}
```
## Syntaxe
{{csssyntax}}
## Exemples
### CSS
```css
:any-link {
color: green;
font-weight: bold;
}
/* Pour les navigateurs WebKit */
:-webkit-any-link {
color: green;
font-weight: bold;
}
```
### HTML
```html
<a href="https://mozilla.org">Une page différente</a><br>
<a href="#">Une ancre</a><br>
<a>Un lien sans cible (n'est pas mis en forme)</a>
```
### Résultat
{{EmbedLiveSample("Exemples","100%","100%")}}
## Spécifications
| Spécification | État | Commentaires |
| ---------------------------------------------------------------------------------------- | ------------------------------------ | -------------------- |
| {{SpecName("CSS4 Selectors", "#the-any-link-pseudo", ":any-link")}} | {{Spec2('CSS4 Selectors')}} | Définition initiale. |
## Compatibilité des navigateurs
{{Compat("css.selectors.any-link")}}
|