--- title: ':link' slug: 'Web/CSS/:link' tags: - CSS - Layout - Pseudo-class - Reference - Selector - Web translation_of: 'Web/CSS/:link' ---
{{ CSSRef }}

The :link CSS pseudo-class represents an element that has not yet been visited. It matches every unvisited {{HTMLElement("a")}}, {{HTMLElement("area")}}, or {{HTMLElement("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 ({{cssxref(":active")}}, {{cssxref(":hover")}}, or {{cssxref(":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 {{cssxref(":any-link")}} to select an element independent of whether it has been visited or not.

Syntax

{{csssyntax}}

Examples

By default, most browsers apply a special {{cssxref("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 {{cssxref("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

{{EmbedLiveSample("Examples")}}

Specifications

Specification Status Comment
{{ SpecName('HTML WHATWG', 'scripting.html#selector-link', ':link') }} {{ Spec2('HTML WHATWG') }}
{{ SpecName('CSS4 Selectors', '#link', ':link') }} {{ Spec2('CSS4 Selectors') }} No change.
{{ SpecName('CSS3 Selectors', '#link', ':link') }} {{ Spec2('CSS3 Selectors') }} No change.
{{ SpecName('CSS2.1', 'selector.html#link-pseudo-classes', ':link') }} {{ Spec2('CSS2.1') }} Lift the restriction to only apply it for {{ HTMLElement("a") }} element.
{{ SpecName('CSS1', '#anchor-pseudo-classes', ':link') }} {{ Spec2('CSS1') }} Initial definition.

Browser compatibility

{{Compat("css.selectors.link")}}

See also