CSS Selector - How to use CSS link Selector :link








The :link selector selects unvisited links.

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

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

The not visited URL is the URL to which the link points does not appear in the user agent's history.

This state is mutually exclusive with the :visited state.

Examples:

a:link  {color: blue;}
*:link {text-decoration: underline;}

Summary

CSS Version
1




CSS Syntax

:link {
   style properties 
}

Browser compatibility

:link Yes 7.0 Yes Yes Yes

Example

An example showing how to use :link CSS selector.

<!DOCTYPE HTML> 
<html> 
    <head> 
        <title>Example</title> 
        <style type="text/css"> 
        :link { <!--from w w w. j a v  a  2  s . c  o 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