Before about 2010, the CSS :visited
selector allowed websites to uncover a user's browsing history and figure out what sites the user had visited. This was done through window.getComputedStyle
and other techniques. This process was quick to execute, and made it possible not only to determine where the user had been on the web, but could also be used to guess a lot of information about the user's identity.
To mitigate this problem, Gecko 2 implemented privacy updates to limit the amount of information that can be obtained from visited links. Other browsers have also made similar changes.
To preserve users' privacy, Firefox and other browsers will lie to web applications under certain circumstances:
window.getComputedStyle
method, and similar functions such as element.querySelector
, will always return values indicating that a user has never visited any of the links on a page.:visited + span
, the adjacent element (span
in this example) will be styled as if the link were unvisited.You can style visited links, but there are limits to which styles you can use. Only the following styles can be applied to visited links:
color
background-color
border-color
(and its sub-properties)column-rule-color
outline-color
fill
and stroke
attributesIn addition, even for the above styles, you won't be able to change the transparency between unvisited and visited links, as you otherwise would be able to using rgba()
, hsla()
, or the transparent
keyword.
Here is an example of how to use styles with the aforementioned restrictions:
:link { outline: 1px dotted blue; background-color: white; /* The default value of background-color is `transparent`. You need to specify a different value, otherwise changes on :visited won't apply. */ } :visited { outline-color: orange; /* Visited links have an orange outline */ background-color: green; /* Visited links have a green background */ color: yellow; /* Visited links have yellow colored text */ }
Overall, these restrictions shouldn't affect web developers too significantly. They may, however, require the following changes to existing sites:
:visited
selector.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/Privacy_and_the_:visited_selector