CSS - :link
The :link
CSS pseudo-class lets you select links inside elements. This will select any link which has not yet been visited, even those already styled using selector with other link-related pseudo-classes like :hover
, :active
or :visited
. In order to appropriately style links, you need to put the :link
rule before the other ones, as defined by the LVHA-order: :link
— :visited
— :hover
— :active
. The :focus
pseudo-class is usually placed right before or right after :hover
, depending on the expected effect.
Example
a:link {color: slategray;} .external:link {background-color: lightblue;}
Syntax
:link <a href="css/value_definition_syntax#curly_braces_(.7b_.7d)" title="Curly braces">{</a> <var>style properties</var> <a href="css/value_definition_syntax#curly_braces_(.7b_.7d)" title="Curly braces">}</a>
Description
The :link
CSS pseudo-class lets you select links inside elements. This will select any link which has not yet been visited, even those already styled using selector with other link-related pseudo-classes like :hover
, :active
or :visited
. In order to appropriately style links, you need to put the :link
rule before the other ones, as defined by the LVHA-order: :link
— :visited
— :hover
— :active
. The :focus
pseudo-class is usually placed right before or right after :hover
, depending on the expected effect.
Browser Compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 1 | 1.0 (1.7 or earlier) | 3.0 | 3.5 | 1.0 |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | 1.5 | 1.0 (1.9.2) | ? | ? | 3.2 |
See Also
Specifications
Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard The definition of ':link' in that specification. |
Living Standard | |
Selectors Level 4 The definition of ':link' in that specification. |
Working Draft | No change. |
Selectors Level 3 The definition of ':link' in that specification. |
Recommendation | No change. |
CSS Level 2 (Revision 1) The definition of ':link' in that specification. |
Recommendation | Lift the restriction to only apply it for <a> element. |
CSS Level 1 The definition of ':link' in that specification. |
Recommendation | Initial definition. |
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/css/:link