Steven Zack
Steven Zack

Reputation: 5104

How to define the link color of a selected hyperlink?

I want the link color to be blue after click it, but not all visited links, not active link not hover link. Why it doesn't work when I use a:selected in my CSS?

Upvotes: 0

Views: 349

Answers (3)

olanod
olanod

Reputation: 30576

Why not using ':visited' selector?

<a href="#">Link</a>

CSS:

a:visited{color:blue;}

:active is when it's been clicked :hover on ... hover :link for non visited links :focus if it has focus and if it's for specific links just add a class

<a href="#" class="special">Special Link</a>

.special:visited{color:blue;}

Upvotes: 0

BoltClock
BoltClock

Reputation: 723528

If you need to modify the color of something after you click it and have that change stick, you need JavaScript. There isn't any pseudo-class in CSS that handles this.

Upvotes: 1

OnResolve
OnResolve

Reputation: 4032

You can wrap the link in a span with a class that changes the visited color to blue. This way you get the effect only on links you wrap in the new span.

Upvotes: 0

Related Questions