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.

:link

Summary

Used to select and style unvisited links.

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 the :link pseudo-class to set the default color attribute of a link in a document.

<style>
    A:link { color:#FF0000 }
</style>

Usage

 The :link pseudo-class is often used with :active, :hover and :visited, the pseudo-classes that affect the other states of a link.

The default value of the :link pseudo-class is browser-specific. The time period used to define a recent visit also varies by browser.

Notes

Note: It is possible for style sheet authors to abuse the :link and :visited pseudo-classes to determine which sites a user has visited without the user’s consent.

UAs may therefore treat all links as unvisited links, or implement other measures to preserve the user’s privacy while 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