1

Is there any quick way to make an :visited link the same color of the link itself?

For example:

* {color:black}
a:link {color:blue}
a:visited {color:inherit}

When I visit the link, this css turns the link on to black.
But I want to preserve the original color of the link (blue, in this case).

I think I can do something like:

a:link, a:visited {color:blue}

But, I have a huge css with many links, with different colors, and without comments from the stupid damned designer who coded this a year ago (me). Apply that solution will be a nightmare, because there are a hundred styles for links.

So... is there any way to override :visited color with the "original" color, without changing the whole stylesheet?

(This is a possible duplicate of this question, but none of the given answers works, and I can't use JS (client requirements).)

Community
  • 1
  • 1
Arkana
  • 2,831
  • 20
  • 35

1 Answers1

0

Until a better answer comes up, there is a partial solution: according to this MDN page, Mozilla defines -moz-visitedhyperlinktext as the "visited" colour for hyperlinks.

So, if you have this HTML:

<a href="#">This is what an a normally looks like</a>
<div class="test">
    <a href="#">This is an a in a black container</a>
</div>
<div class="test">
    <a href="#" style="color:-moz-visitedhyperlinktext">This is a visited a?</a>
</div>

with this CSS:

.test, .test * {color:black}

the a will come out looking "naturally", as you can see in this fiddle. Only in Mozilla.

It won't work in other browsers, but you can write

color:blue;
color:-moz-visitedhyperlinktext;

for the color, and other browsers will ignore the -moz- one.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
  • Yes, especially if you don't also change the background colour to the default. Otherwise you might end up with the same fore- and background colours. – Mr Lister Aug 30 '13 at 18:52
  • I don't know if I understand correctly, but I get the impression that this solution does just the opposite to the expected result? I mean, I don't want a normal link displayed in "visited link" color, but a link "visited" displayed in "normal link" color... argh, what a mess :D – Arkana Sep 02 '13 at 09:14
  • Hm, I should have put `-moz-hyperlinktext` instead of `-moz-visitedhyperlinktext`. But now but I see I totally misinterpreted your question. And I don't think there's an easy solution. `color:currentColor` doesn't work either. So, go through your stylesheets and change all `a:link` into `a` and remove all `a:visited`. – Mr Lister Sep 02 '13 at 10:12
  • However, then the question comes up, why do you want to prevent your users from seeing which pages they have visited? – Mr Lister Sep 02 '13 at 10:14
  • It's because client requirements: we must provide AAA accesibility and the "purple" color of visited links doesn't provide enough contrast with the background (for a few points, damn). So, I thought that if I could keep the default link color and show the visited link with a border, or something.... but as you say, it seems there's no easy solution for this :/ – Arkana Sep 04 '13 at 08:35