How to use CSS link Selector :link

Description

The :link selector selects unvisited links.

Example


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

The code above generates the following result.

:link




















Home »
  HTML CSS »
    HTML CSS Reference »




HTML Tag Reference
CSS Reference
CSS Selector Reference
Encoding Reference