This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

:visited

Summary

The :visited pseudo-class applies to links the user has visited

User agents commonly display unvisited links differently from previously visited ones. Selectors provides pseudo-classes to distinguish them:

  • The :link pseudo-class applies to links that have not yet been visited.
  • The :visited pseudo-class applies once the link has been visited by the user.

After some amount of time, user agents may choose to return a visited link to the (unvisited) ‘:link’ state.

The two states are mutually exclusive.

Examples

The following style rule uses :visited to set the color attribute of visited links in a document.

a:visited { color:blue }

Usage

 :visited  is often used with :active, :hover, and :link, which are the pseudo-classes that reflect the other states of a link.

The default value of the :visited pseudo-class varies by browser, as does the amount of time used to define a recent visit.

Notes

The pseudo-classes :link and :visited can be abused to determine which sites a user has visited.

To preserver their users’ privacy, browsers often implement counter-measures against these abuses, while still rendering visited and unvisited links differently.

Related specifications

CSS 2.1
W3C Recommendation
Selectors Level 3
W3C Recommendation
Selectors Level 4
W3C Working Draft

Attributions