6

I am unable to set the background color for a :visited hyperlink to a different background-color.

Is this a known issue for Google Chrome? I have seen people raising similar issue with background-image. Setting the color attribute seems to be working fine.

This is the code that I used:

a:visited{
    background-color: red;
}
TylerH
  • 20,799
  • 66
  • 75
  • 101
developer
  • 718
  • 9
  • 28
  • 1
    Not a duplicate because the resolution of that one is that background-image isn't supposed to work (for security reasons) but background-color *is*. – hobbs Jul 18 '11 at 01:49
  • 1
    e.g. http://hacks.mozilla.org/2010/03/privacy-related-changes-coming-to-css-vistited/ – hobbs Jul 18 '11 at 01:50

2 Answers2

5

Instead, use the following:

a {
   background-color: white;
}

a:visited{
    background-color: red;
}

For security reasons -- specifically, in order to prevent history sniffing -- Chrome limits very strictly what can be done using the :visited selector.

fletom
  • 1,998
  • 13
  • 17
  • 1
    @praveen That's probably because there's no difference between OP's code and the code in this answer; the a:visited property and value is exactly the same. – TylerH Nov 20 '19 at 14:42
2

Sounds like this is unsupported for security reasons, and will be in Firefox too, as detailed in this answer.

Community
  • 1
  • 1
jtbandes
  • 115,675
  • 35
  • 233
  • 266