vexalist
vexalist

Reputation: 67

How do I set a different color to "visited" anchors in same page?

Is there a way to set a:visited for anchors on the same page?

http://tinker.io/93e4d/3

What happens now is that whatever style I apply to a:visited goes for all the links before I even click. What I need is maybe something like a:clicked instead of visited, or some way to highlight the last link clicked, but I don't know of anything like that.

Is there anything I can do that does not require js?

thanks!

Upvotes: 1

Views: 287

Answers (3)

Jovane Pires
Jovane Pires

Reputation: 3

Set a different class for each anchor.

a.first:visited {}
a.other:visited {}

Upvotes: 0

kiranvj
kiranvj

Reputation: 34147

What happens now is that whatever style I apply to a:visited goes for all the links before I even click.

May be all your links have same href

These should work

a {
   color: red;
}

a:visited {
   color: blue;
}

a:hover {
   color: yellow;
}

Upvotes: 0

Chris par
Chris par

Reputation: 65

To set different colours for your links you could go

#header a:visited {
}
# nav a:visited {
}

Or using a span with a class for each colour

Upvotes: 2

Related Questions