CSS Selector :visited








The :visited selector selects visited links.

:visited is a Pseudo-class and it applies to a hyperlink to another resource that has already been visited.

:visited applies to a link to a URL that has been visited.

Visited URL is the URL to which the link points appears in the user agent's history.

This state is mutually exclusive with the :link state.

Examples:

a:visited  {color: purple;}
*:visited {color: gray;}

Summary

CSS Version
1

CSS Syntax

:visited {
   style properties 
}




Browser compatibility

:visited Yes 7.0 Yes Yes Yes

Example

An example showing how to use :visited CSS selector.

<!DOCTYPE HTML> 
<html> 
    <head> 
        <title>Example</title> 
        <style type="text/css"> 
        :link { <!--   w  ww . jav a 2s.  co  m-->
            border: thin black solid; 
            background-color: lightgrey; 
            padding: 4px; 
            color:red; 
        } 
        :visited { 
            background-color: grey; 
            color:white; 
        } 
        </style> 
    </head> 
    <body> 
        <a href="http://java2s.com">Visit the java2s.com</a> 
        <a href="http://w3c.org">Visit the W3C website</a> 
    </body> 
</html>

Click to view the demo

Only some properties can be applied to links using the :visited selector. You can change the colors and the font.