0

I have a reset.css file which sets a specific color for links. I MUST use this reset file and I cannot remove the link color from there.

So after applying a link color in the reset, I want to override this to use the browsers' standard link color again. Is this possible with CSS2? I'm thinking somehting like:

a:link { color: user-agent; }
transbetacism
  • 585
  • 2
  • 6
  • 17

2 Answers2

3

Once you "reset" the color (technically, replace it with a new value) in a stylesheet, you cannot restore it to the UA default in a way that will work for all UAs. Implementation-specific values and hacks may exist, but there is no standard solution and it is possible that not every implementation will provide or accommodate such a hack.

The best you can do is to approximate the closest color(s) shared by different UAs. The HTML5 spec lists some suggested defaults which you can use as well. See my answer to this question.

Community
  • 1
  • 1
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
2

In webkit you can do:

a {
    color: -webkit-link;
}

a:active {
    color: -webkit-activelink;
}

See this jsfiddle.

You may need to add !important, depending on the priority of the other styles you're trying to override. Unfortunately, I don't know of any alternative for Internet Explorer or Firefox. You might just have to look up their colors and replicate them manually with CSS styles for those platforms specifically. For example, say IE and Firefox use #00f and #30f (they don't, but hypothetically):

a {
    color: #00f;
    color: -webkit-link;
}

a:active {
    color: #30f;
    color: -webkit-activelink;
}

Because IE and Firefox don't recognize the -webkit-prefixed colors, they'll just fall back to the previous colors declared.

0x24a537r9
  • 968
  • 1
  • 10
  • 24