CSS :link Selector

Complete CSS Reference Complete CSS Reference

Example

How to style links (<a> elements with an href):

a:link
{
background-color:yellow;
}

Try it yourself »

Definition and Usage

The :link selector styles unvisited links.

Note: The :link selector does not style links to pages you have already visit.

Tip: Use the :visited selector to style links to visited pages.

Tip: Use the :hover selector to style links when you mouse over them.

Note: :hover MUST come after :link and :visited (if they are specified) in the CSS definition in order to be effective!

Tip: Use the :active selector to style links when you click on them.

Note: :active MUST come after :hover (if specified) in the CSS definition in order to be effective!


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The :link selector is supported in all major browsers.


CSS Version

The :link selector was first introduced in:

CSS 1


Related Pages

CSS tutorial: CSS Links

CSS tutorial: CSS Pseudo classes


Examples

Try it Yourself - Examples


Example

How to style a link, unvisited, visited, active, and when you mouse it:

a:link    {color:green;}
a:visited {color:green;}
a:hover   {color:red;}
a:active  {color:yellow;}

Try it yourself »

Example

How to give different links different styles:

a.ex1:hover,a.ex1:active {color:red;}
a.ex2:hover,a.ex2:active {font-size:150%;}

Try it yourself »

Complete CSS Reference Complete CSS Reference