ControlAltDel
ControlAltDel

Reputation: 35106

Possible to disable a:visited?

I've got a page listing information, where you can click a link to get more details. Most of these links are normal (i.e. no class) but on some I have set the class "unpublished" (for unpublished changes) where the style is set to color: red

Because of a:visited, if either a blue link or a red link is clicked on, it then appears purple (visited). I could set a:visited {color: blue} or {color: red}, but that's going to screw up either the links that otherwise would have been colored red or the ones that would have been colored blue.

Is it possible somehow to disable style a:visited entirely? If not, is there another way to work around this issue?

Upvotes: 2

Views: 6793

Answers (3)

Johannes
Johannes

Reputation: 67799

I usually create one common rule for the regular link and the visited state, so visited links always look like "regular", unvisited links.

a:link, a:visited {
  [ ...settings here... ]
}

Upvotes: 2

IceWreck
IceWreck

Reputation: 127

There isn't some super-code that does that. But you can configure your CSS in the following way:

Main Link Color:

a{color:blue;}

Visited Link Color:

a:visited {color:blue;}  

Replace Blue with your own color. This will set your main link color and visited link color to the same and achieve your desired result.

Upvotes: 0

Laurens
Laurens

Reputation: 2607

You can overwrite a:visited{...} with your own style. For example, if you want the link to stay red for unpublished visited links, then you do:

a.unpublished:visited{
    color:red;
}

If you just want the anchor color to stay the same as the anchor's parent element you can use inherit:

a:visited {
  color: inherit;
}

Upvotes: 5

Related Questions