The :visited pseudo-class targets hyperlinks the user has already clicked. Pair it with :link so visitors can tell which pages they have explored and which are still new.
01
Visited
Already clicked.
02
a:visited
Anchor only.
03
:link
Pair together.
04
LVHA
Step two.
05
Privacy
Safe props.
06
Navigation
Track progress.
Fundamentals
Introduction
The CSS :visited selector targets links that the user has already visited. It is a pseudo-class that helps differentiate between visited and unvisited hyperlinks, improving navigation and usability on websites.
By applying specific styles to visited links — such as a muted purple color or an underline — you help users track their browsing history and avoid re-reading content they have already seen.
Definition and Usage
Write a:visited to style anchor elements with an href attribute after the browser records that URL in the user’s visit history. Once visited, the link no longer matches :link and instead uses your :visited rules.
💡
Beginner Tip
Always style both :link and :visited. If they look identical, users cannot tell which articles, docs, or menu items they have already opened.
Foundation
📝 Syntax
The syntax for the :visited pseudo-class is:
syntax.css
a:visited{/* CSS properties */}
The :visited pseudo-class applies only to <a> elements that have an href attribute and are in the visited state.
Browsers limit which properties can change on :visited links to protect browsing history. These properties are allowed:
Allowed property
Example use
color
Purple or muted gray text for visited links
background-color
Light tint behind visited menu items
border-color
Subtle border change on visited cards
outline-color
Focus ring color on visited anchors
text-decoration-color
Underline color for visited inline links
Not allowed on :visited: Properties like display, visibility, content, font-size, and background-image cannot be used — they could leak which sites a user has visited.
Syntax Rules
Only matches <a> elements with an href attribute.
Applies after the browser records the URL in the user’s history.
Declare after :link and before :hover and :active (LVHA).
Stick to privacy-safe color properties for reliable cross-browser results.
Pair with :link so unvisited and visited links look distinct.
After a user clicks a link, the browser switches from a:link to a:visited. The purple color and underline signal that the destination has already been opened.
Example 2 — Visited navigation links
Mute visited menu items with a softer gray while keeping unvisited items dark and bold.
visited-nav.css
nav a:link{color:#1e293b;text-decoration:none;font-weight:600;}nav a:visited{color:#94a3b8;font-weight:500;}nav a:hover{background-color:#e2e8f0;}
Browsers allow color, background-color, and border-color on visited links. Properties like width or content are blocked to protect user privacy.
Tips
💬 Usage Tips
Pair with :link — Always define both unvisited and visited styles together.
LVHA order — Place :visited immediately after :link in your stylesheet.
Use color contrast — Visited links should still be readable against the page background.
Stick to safe properties — Use color, background-color, and border-color for reliable results.
Scope when needed — Use nav a:visited or .sidebar a:visited for targeted menus.
Watch Out
⚠️ Common Pitfalls
Identical :link and :visited styles — Users cannot tell which pages they have already opened.
Blocked properties — font-size, display, content, and background-image do not work on :visited links.
Wrong LVHA order — Declaring :hover before :visited can prevent hover styles from appearing on visited links.
Missing href — :visited does not apply to <a> elements without an href attribute.
Cache confusion — Browser history can make a link appear visited even if the user did not click it recently; clearing history resets the state.
A11y
♿ Accessibility
Do not rely on color alone — Combine color changes with underline, weight, or icons (on the unvisited state) for clarity.
Maintain contrast — Visited link colors must still meet WCAG AA contrast ratios (4.5:1 for normal text).
Focus indicators — Add :focus-visible styles so keyboard users can navigate links.
Meaningful link text — Describe the destination; visited state is a bonus cue, not a replacement for clear labels.
Cognitive support — Visited styling helps users with memory challenges track what they have already read.
🧠 How :visited Works
1
User clicks a link
The browser navigates to the URL and records it in local visit history.
Click
2
State changes to visited
On return visits, the anchor no longer matches :link.
State
3
:visited styles apply
Only privacy-safe properties like color and background-color take effect.
Style
=
🔗
Browsing context
Users see which links are fresh and which they have already explored.
Compatibility
🖥 Browser Compatibility
The :visited pseudo-class is supported in all modern browsers. Privacy restrictions on allowed properties are enforced consistently.
✓ Baseline · Universal support
Visited link styling everywhere
:visited works reliably in Chrome, Firefox, Safari, Edge, and Opera with privacy-safe property limits.
99%Universal support
Google ChromeAll versions · Privacy limits enforced
Full support
Mozilla FirefoxAll versions · Privacy limits enforced
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions
Full support
OperaAll modern versions
Full support
:visited pseudo-class99% supported
Bottom line::visited is safe for all hyperlink visited-state styling; use only color-related properties for cross-browser consistency.
Wrap Up
🎉 Conclusion
The CSS :visited selector is a simple yet effective way to style visited links, helping users distinguish between pages they have already explored and those they have not.
While browser security measures limit which properties can be applied, the selector still plays an important role in enhancing website navigation and user experience. Pair it with :link, :hover, and :active in LVHA order for a complete link styling system.
The :visited pseudo-class matches anchor elements with an href attribute that the user has already visited. It lets you style clicked hyperlinks differently from unvisited ones so users can track where they have been.
:visited only applies to a elements that have an href attribute and are in the visited state. It does not match buttons, spans, or anchors without href.
Browsers restrict which CSS properties can change on :visited links to prevent websites from fingerprinting a user's browsing history. Only color-related properties like color, background-color, and border-color are allowed.
Declare :link first, then :visited, then :hover, then :active. This LVHA order prevents later states from being overridden incorrectly in the cascade.
Yes. All modern browsers support :visited for hyperlink styling. The privacy restrictions on allowed properties are also enforced consistently across Chrome, Firefox, Safari, and Edge.