The :link
CSS pseudo-class represents an element that has not yet been visited. It matches every unvisited <a>
or <area>
element that has an href
attribute.
The :link
CSS pseudo-class represents an element that has not yet been visited. It matches every unvisited <a>
or <area>
element that has an href
attribute.
Styles defined by the :link
and :visited
pseudo-classes can be overridden by any subsequent user-action pseudo-classes (:hover
or :active
) that have at least equal specificity. To style links appropriately, put the :link
rule before all other link-related rules, as defined by the LVHA-order: :link
— :visited
— :hover
— :active
. The :visited
pseudo-class and :link
pseudo-class are mutually exclusive.
Note: Use :any-link
to select an element independent of whether it has been visited or not.
:link { /* ... */ }
By default, most browsers apply a special color
value to visited links. Thus, the links in this example will probably have special font colors only before you visit them. (After that, you'll need to clear your browser history to see them again.) However, the background-color
values are likely to remain, as most browsers do not set that property on visited links by default.
<a href="#ordinary-target">This is an ordinary link.</a><br /> <a href="">You've already visited this link.</a><br /> <a>Placeholder link (won't get styled)</a>
a:link { background-color: gold; color: green; }
Specification |
---|
HTML Standard # selector-link |
Selectors Level 4 # link |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
:link |
1 | 12 | 1 | 3 | 3.5 | 1 | 1.5 | 18 | 4 | 14 | 3.2 | 1.0 |
not_match_link |
1 | 12 | 87 | No | 3.5 | 15 | 1.5 | 18 | 87 | 14 | 15 | 1.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/:link