The :link pseudo-class targets unvisited anchor links. It is the foundation of hyperlink styling alongside :visited, :hover, and :active.
01
Unvisited
Not clicked yet.
02
a:link
Anchor only.
03
Needs href
Real links.
04
LVHA
Correct order.
05
:visited
Pair together.
06
Navigation
Menu styling.
Fundamentals
Introduction
The CSS :link selector is used to target unvisited links on a webpage. It allows you to style hyperlinks that have not been clicked yet, helping differentiate between visited and unvisited links.
This is useful for enhancing user experience by visually guiding users through available links on your site.
Definition and Usage
Write a:link to style anchor elements with an href attribute in their default, unvisited state. Once a user visits the URL, the link moves to the :visited state instead.
💡
Beginner Tip
Always declare link pseudo-classes in LVHA order: :link, :visited, :hover, :active. Wrong order can cause hover styles to be overridden by visited styles.
Foundation
📝 Syntax
The syntax for the :link pseudo-class is:
syntax.css
a:link{/* CSS properties */}
The :link pseudo-class only applies to <a> elements that have an href attribute and are in their unvisited state.
:focus-visible shows a focus indicator only for keyboard navigation, keeping mouse clicks clean while meeting accessibility requirements.
Tips
💬 Usage Tips
Pair with :visited — Always style both so users can distinguish clicked and unclicked links.
LVHA order — Declare :link, :visited, :hover, :active in that sequence.
Include :focus — Add :focus-visible for keyboard accessibility.
Scope selectors — Use nav a:link or .content a:link for targeted styling.
Contrast matters — Ensure link colors stand out from body text and meet WCAG contrast ratios.
Watch Out
⚠️ Common Pitfalls
Missing href — :link does not apply to <a> without an href attribute.
Same styles for :link and :visited — Users cannot tell which links they have already opened.
Wrong LVHA order — Hover or active styles may not appear if declared before :visited.
Removing all underlines — Without another visual cue, links can be hard to spot in paragraphs.
Styling buttons as links — Use <button> for actions; reserve <a> for navigation.
A11y
♿ Accessibility
Visible links — Do not rely on color alone; use underline, icons, or bold weight where needed.
Focus indicators — Never remove focus outlines without providing an alternative (:focus-visible).
Contrast ratios — Link text must meet WCAG AA contrast against its background (4.5:1 for normal text).
Meaningful link text — Avoid “click here”; describe the destination in the anchor text.
Visited state — Helps users with cognitive disabilities track where they have been.
🧠 How :link Works
1
Anchor has href
The browser identifies <a href="..."> as a hyperlink.
HTML
2
Check visit history
If the URL is not in browser history, the link is in the unvisited state.
State
3
:link styles apply
CSS rules for a:link set the default unvisited appearance.
Style
=
🔗
Clear navigation
Users see which links are fresh and which they have already explored.
Compatibility
🖥 Browser Compatibility
The :link pseudo-class is supported in all modern browsers and has been available since CSS1.
✓ Baseline · Universal support
Link styling everywhere
:link works reliably in Chrome, Firefox, Safari, Edge, and Opera.
99%Universal support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions
Full support
OperaAll modern versions
Full support
:link pseudo-class99% supported
Bottom line::link is safe for all hyperlink styling in modern projects.
Wrap Up
🎉 Conclusion
The CSS :link selector is a handy tool for styling hyperlinks that have not been clicked. It allows customization of unvisited links, enhancing visual clarity and navigation.
Pair it with :visited, :hover, and :active in LVHA order to create a consistent and engaging design for your website’s links.
The :link pseudo-class matches anchor elements with an href attribute that the user has not yet visited. It lets you style unvisited hyperlinks differently from visited ones.
Yes. The :link pseudo-class only applies to a elements that have an href attribute and are in the unvisited state. Anchors without href are not links.
Declare link pseudo-classes in this order to avoid cascade conflicts: :link, :visited, :hover, :active. This mnemonic is often called LVHA or LoVe HAte.
:link styles hyperlinks the user has not clicked yet. :visited styles links the browser has already visited. Always style both so users can tell them apart.
Yes. All modern browsers support :link. It has been a core CSS feature since CSS1 and works reliably for navigation and inline hyperlinks.