Link's property :visited doesn't work

Even without being visited links are green color. Hover works as it should - changes color to blue.
I don’t understand why :visited doesn’t work.

a:link {
color: red;
}
a:visited {
color: green;
}
a:hover {
color: blue;
}

1 Like

I tested it, it works, here’s the link It only warned me that expected empty line before ruleset so I added an empty line before each ruleset and it works
Hope this helps :grinning:

visited links only take the color if the link has been clicked before. It will be recorded in the browser’s history as having been followed during this or a previous session.

It’s important that your rules are written in the order in which you have them in your example.

There is one other pseudo-class that applies to keyboard navigation using TAB.

a:focus

and one that applies when the link is clicked,

a:active

The correct order for all five is,

:link 
:visited 
:hover
:focus
:active 

LiVe HAppy.

hover and focus may be switched around. The rest of the order is critical.

1 Like

Yep, it really works in your example and also it works in several other websites which I checked but it doesn’t want work on my computer(( I even created quite new html and css files with only 3 links and their stles like in my example…the result is the same: links become at once :visited color and only :hover works…

1 Like

thank you for you reply

1 Like

I’m very grateful for your extended reply…I did everything like it should be (the order as in your example) before I wrote here but it doesn’t want to work on my computer(( I even created quite new html and css files with only 3 links and their stles like in my example…the result is the same: links become at once :visited color and only :hover works…

2 Likes

That’s because they are recorded in the history. Create a new link with fresh text and a different URL. It should be red. Once you click that link it will be green.

2 Likes

That’s it!
I thought about this issue and even tried to clear history before your reply but perhaps I didn’t clear it properly.
I’ve just tried with new link and it works as it should work
I’m very grateful you:)

2 Likes