:link
:link– pseudo-class | CSS Level 1
The :link
selects links that have not been visited. This selector targets <a>
elements with href
attribute, even if href
attribute is empty.
Syntax
:link {
color: blue;
}
The :link
pseudo-class selects only <a>
elements and only with href
attribute. So :link
styles have no effects in following examples:
<div>I am a div element.</div>
<p href="#">I am a paragraph with a href attribute which is invalid in the HTML.</p>
<a>I am the a element but I don't have a href element.</a>
<div href>I am a div element with empty a href attribute</div>
Selecting all <a>
elements with and without a href
attribute can be done by using only the <a>
element:
a {
color: blue;
}
If the :link
is listed with the :visited
, :hover
and :active
, the :link
must be placed at the top of the list before other pseudo-classes.
a:link {
color: blue;
}
a:visited {
color: purple;
}
a:hover {
color: green;
}
a:active {
color: red;
}