Understanding the :visited Pseudo-Class
The :visited pseudo-class in CSS applies styles to links (<a> elements) that the user has previously visited. This allows designers to visually differentiate between links that have been clicked and those that haven't.
In this example, links that the user has not visited appear blue, while visited links appear purple.
Use :visited to provide visual cues about link history, improving navigation experience.
Browsers restrict which CSS properties can be applied to :visited for privacy reasons (e.g., color changes are allowed, but background images are typically blocked).
Combine :visited with :hover and :active for consistent interactive feedback.
Test link styling across browsers, as some may handle visited links differently to prevent history leakage.
You need to style links that the user has already visited to appear purple. How would you write the CSS selector, and what are the limitations you need to be aware of?
If a user’s browser is set to block history sniffing, what will happen to the colors you apply with :visited?
We have a component that conditionally adds a class to links based on whether they’re internal or external. After deploying, the visited styling stopped working on some pages. Walk me through how you would debug this.
Explain why changing the background-image of a :visited link is ignored by browsers, and how you would achieve a visual indication of visited state without violating privacy restrictions.
Our site uses a CSS-in-JS library that generates class names at runtime. How would you ensure that :visited styles are applied consistently across server‑rendered and client‑only components, considering browser privacy rules?
Discuss the performance and security trade‑offs of using :visited to indicate read status in a large news platform with millions of users, and propose an alternative approach if needed.
We are migrating a legacy monolith to a micro‑frontend architecture. Different teams own different style systems, and some still rely on :visited for user‑read tracking. How would you standardize link styling while avoiding cross‑team privacy regressions?
Consider a scenario where a third‑party widget injects its own stylesheet that overrides your :visited rules. What governance or tooling would you put in place to prevent unintended side effects at scale?