CSS Reference ยท Pseudo-classes
The :link pseudo-class
Reference for the CSS :link pseudo-class: style hyperlinks that have not been visited, with syntax, the LVHA order, examples, usage notes and browser support.
The :link pseudo-class matches hyperlinks that have an href and have not been visited. In HTML that means <a> and <area> elements with an href attribute whose target is not in the browser's history. Once the user has been to that address, the link matches :visited instead.
An <a> without href is a placeholder and matches neither.
CSS
a:link { color: #2563eb; }
Try it
Syntax
CSS
:link { /* declarations */ }
No arguments; specificity (0,1,0), the same as :visited, :hover and :active.
Syntax and arguments
| Part | Description |
|---|---|
:link |
Matches links with an href that the browser has not recorded as visited. |
| No arguments | The pseudo-class is not functional. |
| Needs | An element that is a hyperlink (a[href], area[href]). |
Usage notes
- LVHA order. Write link rules as
:link,:visited,:hover,:active. All four have equal specificity, so later rules override earlier ones. - Plain
avsa:link. A barearule also reaches anchors withouthref;a:linkdoes not, and it has higher specificity thana. - Visited links are special. After a visit the element no longer matches
:link. Style shared traits onaor:any-linkand only the differences on:linkand:visited. - Don't rely on colour alone. Links inside text should remain recognisable by an underline or other cue, not just a colour change.
- Dynamic matching. The state can change during a session, for example when the user returns from a page they just opened.
Browser support
Supported in every browser.
Related
:visitedโ visited links:any-linkโ both states in one selector:hoverโ pointer over the element- Lesson: Pseudo-classes