English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules (RULES)

Comprehensive List of CSS Properties

CSS :link Selector

:link pseudo-class selector is used to select links within elements. It will select all unvisited links, including those that have already been given other pseudo-class selectors (such as :hover selector, :active selector, :visited selector). To correctly render the styles of link elements, the :link pseudo-class selector should be placed before other pseudo-class selectors and follow the LVHA order, that is: :link — :visited — :hover — :active. The :focus pseudo-class selector often accompanies the :hover pseudo-class selector, and the order should be determined according to the effect you want to achieve.

Complete CSS Selector Reference Manual

Online Example

Select the style of unvisited hyperlinks:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Basic Tutorial(oldtoolbag.com)</title> 
<style> 
a:link
{
background-color:lightgreen;
}
</style>
</head>
<body>
<a href="//www.oldtoolbag.com">oldtoolbag.com</a>
<a href="//www.baidu.com" target="_blank">baidu.com</a>
<a href="//www.pcjson.com" target="_top">pcjson.com</a>
<p><b>Note:</b>:link selects the style link to the page you have not visited.</p>
</body>
</html>
Test and see ‹/›

Definition and Usage

:link adds special styles to unvisited links.

Note: :link selector does not have a style for visited links.

Prompt: Use :visited The selector sets the style of visited page links.:hoverSelector for the style of the link when the mouse is hovering over it:active Selector sets the style when you click the link.

Browser Compatibility

The numbers in the table indicate the first browser version that supports the attribute.

Selector




:link4.07.02.03.19.6

Related Pages

CSS Tutorial: CSS Links

CSS Tutorial: CSS Pseudo-classes

Online Example

Active, visited, unvisited, or when the mouse is hovering over the link:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Basic Tutorial(oldtoolbag.com)</title> 
<style>
a:link {color:green;}
a:visited {color:green;}
a:hover {color:red;}
a:active {color:yellow;}
</style>
</head>
<body>
<p>Move the mouse over and click this link: <a href="//www.oldtoolbag.com/">oldtoolbag.com</a></p>
</body>
</html>
Test and see ‹/›

Online Example

Different styles of link styles:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Basic Tutorial(oldtoolbag.com)</title> 
<style>
a.ex1:hover,a.ex1:active {color:red;}
a.ex2:hover,a.ex2:active {font-size:150%;}
a.ex3:hover,a.ex3:active {background:red;}
a.ex4:hover,a.ex4:active {font-family:monospace;}
a.ex5:visited,a.ex5:link {text-decoration:none;}
a.ex5:hover,a.ex5:active {text-decoration:underline;}
</style>
</head>
<body>
<p>Move the mouse over the link to see the style change./p>
<p><a class="ex1" href="/css/">This link changes the color</a></p>
<p><a class="ex2" href="/css/">This link changes the font size</a></p>
<p><a class="ex3" href="/css/">This link changes the background color</a></p>
<p><a class="ex4" href="/css/">This link changes the font type</a></p>
<p><a class="ex5" href="/css/">This link changes the text decoration</a></p>
</body>
</html>
Test and see ‹/›
Complete CSS Selector Reference Manual