:visited CSS Pseudo Class

Description

The :visited pseudo-class in CSS is used to target and style hyperlinks that have been visited by the user. When a user clicks on a link and visits the corresponding web page, the link enters the "visited" state. The :visited pseudo-class allows developers to apply different styles to visited links, making it easier for users to identify which links they have already visited.

However, due to security and privacy concerns, most modern web browsers limit the styles that can be applied to visited links. This limitation helps prevent malicious websites from determining a user's browsing history by checking which links are styled differently.

Despite these restrictions, developers can still customize certain properties such as color, background-color, and text-decoration for visited links, providing a degree of flexibility in designing user-friendly and intuitive websites.

Syntax

:visited {
  /* ... */
}

Example

<a href="#test-visited-link">Have you visited this link yet?</a><br />
<a href="">You've already visited this link.</a>
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;
}

Browser Support

The following table will show you the current browser support for the CSS :visited pseudo class.

Desktop
Edge Chrome Firefox Opera Safari
12113.51
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
18410.1114.4

Last updated by CSSPortal on: 1st October 2023