:link and :visited, pseudo-classes related to links.
Summary of characteristics of the :link selector
Description of the pseudo-classes :link and :visited.
These selectors refer to hyperlinks, in other words to the following HTML tags: a and area when an href attribute is present.
:linkrefers to unvisited links.:visitedon the contrary, refers to links that have already been visited.
Visited links stay in this state for a certain number of days, at the browser's discretion. The user can also clear the browsing history, which will reset all the links to unvisited.
Many conflicts can arise because the same link can be targeted both by the pseudo-class :link, by the pseudo-class :active,
by the pseudo-class :any-link, and by a direct selector on the tags that contain the link, like a, area, etc.
The rules are as follows:
- The three pseudo-classes
:link,:active, and:any-linkhave the same priority. So the rule that comes last will be the one that counts. - Selectors on the a, area, and link tags have lower priority, no matter where they are. So it's always the rules on pseudo-classes that are considered, even if they come before.
For a more complete explanation on resolving conflicts in CSS, check out the tutorial at Priorities.
Note: there is now a pseudo-class that allows you to target all links, visited or not: :any-link.
Examples of using link-related pseudo-classes.
Difference between visited links and unvisited links.
This first set of examples shows the difference between visited links and unvisited links. The former are shown in red, and unvisited links in gray. By clearing your browsing history, you can reset the already visited links back to their 'unvisited' state.
So he's still in the visited state.
It will be in the visited state once you've clicked it for the first time.
He will never be in the visited state.
Priority over the selector on a.
Tag selectors have a lower priority than pseudo-class selectors. As a result, the rule that targets a tags is never activated, even though
it comes after the ones targeting the pseudo-classes :link and :visited.
He is still in the visited state.
The rule regarding the a tag is not enabled.
He will never be in the visited state.
The rule regarding the a tag isn't enabled either.
Priority over :any-link.
The pseudo-class :any-link has the same specificity as the pseudo-classes :link and :visited.
So it's the last rule encountered that is active, as shown in the example below.
He is still in the visited state.
Le sélecteur
:any-link venant après le sélecteur :visited, c'est lui qui est activé.
Il ne sera jamais dans l'état visité.
Le sélecteur
:link venant après, c'est lui qui est activé.
Browser compatibility.
The pseudo-classes :link and :visited are well recognized by all browsers.
:link pseudo-class to target links.:visited pseudo-class, which targets links that have already been visited.:linkpseudo-class
:visitedpseudo-class
Browsers on computers :
Mobile browsers :
Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Safari

Samsung Internet

Opéra

Safari sur IOS

Firefox

Firefox pour Androïd

Edge

Chrome

Androïd Brower

KaiOS Browser

Chrome pour Androïd

Opéra mini
History of pseudo-classes :link and :visited.
-
Cascading Style Sheets Level 2 - Revision 1 Specification
This level 2 of the specification describes the mechanism of cascading styles in CSS. This language is used to format HTML or XML documents. It supports media-specific style sheets so that authors can adapt the presentation of their documents for visual browsers, auditory devices, printers, braille devices, portable devices, etc.
Regarding:linkIntroduction of the:linkand:visitedpseudo-classes.November 04, 1997Working Draft.March 24, 1998Proposed for recommendation.May 11, 1998Recommendation . -
Selectors Level 3
This document describes the selectors that already exist in CSS1 and CSS2, and further introduces new selectors for CSS3 and other languages that may need them.
Regarding:linkNo change to the:linkand:visitedpseudo-classes.August 03, 1999Working Draft.November 13, 2001Candidate Recommendation.December 15, 2009Proposed for recommendation.September 29, 2011Recommendation . -
Selectors Level 4
This specification module defines new selectors that can be used in CSS.
Regarding:linkNo change to the:linkand:visitedpseudo-classes.September 29, 2011Working Draft.
See also...
Several pseudo-classes allow you to target links on a page, or parts of a page specified by the URL (bookmark). Check the pages describing the selectors below to complete your information.
href attribute.





