W3cubDocs

/CSS

:link

The :link CSS pseudo-class represents an element that has not yet been visited. It matches every unvisited <a>, <area>, or <link> element that has an href attribute.

/* Selects any <a> that has not been visited yet */
a:link {
  color: red;
}

Styles defined by the :link pseudo-class will be overridden by any subsequent link-related pseudo-class (:active, :hover, or :visited) that has at least equal specificity. To style links appropriately, put the :link rule before all other link-related rules, as defined by the LVHA-order: :link:visited:hover:active.

Note: Use :any-link to select an element independent of whether it has been visited or not.

Syntax

:link

Examples

By default, most browsers apply a special color value to visited links. Thus, the links in this example will probably have special font colors only before you visit them. (After that, you'll need to clear your browser history to see them again.) However, the background-color values are likely to remain, as most browsers do not set that property on visited links by default.

HTML

<a href="#ordinary-target">This is an ordinary link.</a><br>
<a href="">You've already visited this link.</a><br>
<a>Placeholder link (won't get styled)</a>

CSS

a:link {
  background-color: gold;
  color: green;
}

Result

Specifications

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 1 Yes 1 3 3.5 1
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support 1.5 ? Yes 4 ? 3.2 ?

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/:link