:visited

The :visited CSS pseudo-class represents links that the user has already visited. For privacy reasons, the styles that can be modified using this selector are very limited.

/* Selects any <a> that has been visited */
a:visited {
  color: green;
}

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

Styling restrictions

For privacy reasons, browsers strictly limit which styles you can apply using this pseudo-class, and how they can be used:

Note: For more information on these limitations and the reasons behind them, see Privacy and the :visited selector.

Syntax

:visited

Example

Properties that would otherwise have no color or be transparent cannot be modified with :visited. Of the properties that can be set with this pseudo-class, your browser probably has a default value for color and column-rule-color only. Thus, if you want to modify the other properties, you'll need to give them a base value outside the :visited selector.

HTML

<a href="#test-visited-link">Have you visited this link yet?</a><br>
<a href="">You've already visited this link.</a>

CSS

a {
  /* Specify non-transparent defaults to certain properties,
     allowing them to be styled with the :visited state */
  background-color: white;
  border: 1px solid white;
}

a:visited {
  background-color: yellow;
  border-color: hotpink;
  color: hotpink;
}

Result

Specifications

Specification Status Comment
HTML Living Standard
The definition of ':visited' in that specification.
Living Standard  
Selectors Level 4
The definition of ':visited' in that specification.
Working Draft No change.
Selectors Level 3
The definition of ':visited' in that specification.
Recommendation No change.
CSS Level 2 (Revision 1)
The definition of ':visited' in that specification.
Recommendation Lifts the restriction to only apply :visited to the <a> element. Lets browsers restrict its behavior for privacy reasons.
CSS Level 1
The definition of ':visited' in that specification.
Recommendation Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
:visitedChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 4Opera Full support 3.5Safari Full support 1WebView Android Full support 4.4Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0
:visited no longer matches <link> elementsChrome Full support 1
Notes
Full support 1
Notes
Notes Chromium has never matched <link> elements with link pseudo-classes.
Edge Full support 12Firefox Full support 70IE No support NoOpera Full support 15
Notes
Full support 15
Notes
Notes Chromium has never matched <link> elements with link pseudo-classes.
Safari Full support 12WebView Android Full support 4.4
Notes
Full support 4.4
Notes
Notes Chromium has never matched <link> elements with link pseudo-classes.
Chrome Android Full support 18
Notes
Full support 18
Notes
Notes Chromium has never matched <link> elements with link pseudo-classes.
Firefox Android No support NoOpera Android Full support 14
Notes
Full support 14
Notes
Notes Chromium has never matched <link> elements with link pseudo-classes.
Safari iOS Full support 12Samsung Internet Android Full support 1.0
Notes
Full support 1.0
Notes
Notes Chromium has never matched <link> elements with link pseudo-classes.
Restrict CSS properties allowed in a statement using :visited for privacyChrome Full support 6Edge Full support 12Firefox Full support 4IE Full support 8Opera Full support 15Safari Full support 5WebView Android Full support 37Chrome Android Full support 18Firefox Android Full support 4Opera Android ? Safari iOS Full support 4.2Samsung Internet Android Full support 1.0

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

See also