The link pseudo-classes

Back to the index.

The :link pseudoclass targets links the user has not yet visited. The :visited pseudoclass targets links the user has already visited. The :any-link pseudo-class targets any link, visited or unvisited.

Both links should be uppercase. The unvisited link should be red, the visited one green and possibly bold. JavaScript should report the same color and font-weight values for both links.

:any-link {
	text-transform: uppercase;

:link {
	color: red;

:visited {
	color: green;
	font-weight: bold;

:visited and security

The problem with this selector is security. If a malicious site owner lures you to a page with a lot of links, and then reads out the styles of those links and compares them to the :visited styles, he knows which sites you’ve visited.

To combat this security hole, browsers generally only allow you to set color-related properties, and JavaScript reports the unvisited, regular color. See this article for more information.