Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset link colour to browser default

Tags:

css

Is there a way to reset visited and unvisited link colours to the browser default after they have been changed?

In my specific situation, I have a main style file containing:

a:link    { color: black; }
a:visited { color: black; }

And I would like to have a few specific links rendered with the default colours.

EDIT: Here is a jsFiddle to play with. I would like a style for the default class that makes it match the browser default.

like image 964
Mangara Avatar asked Feb 16 '23 13:02

Mangara


2 Answers

Edit:

Another way is avoiding the problem from the beginning. Give the special links you want to be with the default style a special class (let's call it .default), and instead of:

a:link    { color: black; }
a:visited { color: black; }

Use the not pseudo class and write:

a:not(.default):link    { color: black; }
a:not(.default):visited { color: black; }

Notice that this pseudo class doesn't work on IE 8 and lower. For them you can use a special CSS (I don't like it, but it'll work).

like image 160
Itay Avatar answered Feb 22 '23 13:02

Itay


It is different for each browser.

What you would have to do is get a stylesheet from the browser you are trying to reset (Gecko, WebKit, or Trident) and make that the new default.

Source: Browsers' default CSS for HTML elements

like image 24
doitlikejustin Avatar answered Feb 22 '23 14:02

doitlikejustin