Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS color Anchor, but not A:hover

Tags:

css

I want to change the color of anchor tags of a certain class, but only when they are not hovered. Hovered anchors of the same class should retain the color of unclassed anchors (whatever the other stylesheets have done to them).

For example, given:

a {color: [unknown color];} /* set elsewhere, out of my control */

a.incognito {color:inherit} /* the text color, typically black */
a.incognito:hover {color: [what?];} /* the color of a non-incognito anchor */

Is there a CSS-only solution to have the hovered link not use the color style of the unhovered link of the same class?

like image 607
Umbrella Avatar asked May 06 '13 15:05

Umbrella


1 Answers

You can use the CSS3 :not() modifier:

a.incognito:not(:hover) {color:inherit} /* the text color, typically black */

Note that this is not supported by IE <= 8.

like image 169
SLaks Avatar answered Nov 01 '22 04:11

SLaks