By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

The CSS Link Selector

The Link Pseudo-class is used to select unvisited links on a page.

Edited: 2012-10-06 07:10

The CSS :link selector is used to select unvisited links – the browser remembers which URLs has been visited by the user, making it possible to style visited and unvisited links separate of each other.

Using the :link Selector is a good idea whenever wanting to style your links. Giving visited links a different style than unvisited, can increase the usability of your site.

:link is a member of the pseudo-classes of CSS. Some of these classes, such as :hover, will also work on non-link elements.

The :link selector can be used as follows:

.nav a:link {color:blue;} /* A's inside parents that are members of the nav class */
a:link {color:blue;} /* Will select a elements that are links */
.MyClass:link /* Will select elements in the MyClass class that are links */

The below piece of CSS code will target visited and unvisited links separately, giving them a unique color to easily tell them apart from each other:

a:link { color: blue; }
a:visited { color: purple; }

More on Link Styling

The below may also be of interest to you:

  1. Effects on Links – Tutorial on HTML/CSS