Why does not the color of the link visited change when I give the absolute link in the anchor tag?


I have made a link in html using anchor tag. I have defined an unvisited color and a visited color for the link in css as follows :

  bottom: 20px;
  right: 30px;
  font-family: Verdana, Arial, Helvetica, sans-serif;
  font-size: 10px;
  font-weight: bold;

#menu a:link{color:blue;}
#menu a:visited{color:red;}

HTML code:

<div align = " right" id="menu">
<a  href="D:\MyFolder\ContactUs.html">Contact Us</a>

When I give the relative address in "href" attribute of anchor tag, everything is working fine.

e.g. href = "ContactUs.html" --since they are in same folder

But when I give the absolute address in "href" attribute of anchor tag, the color is not changing from "blue" to "red" on visiting the page. It remains "blue" only.

e.g. href = "D:\MyFolder\ContactUs.html"

Kindly explain why is it so ?

Note that the css class is for visited not clicked.

So when you click on <a href="D:\MyFolder\ContactUs.html">Contact Us</a> and the browser automatically detects that it is a file, it redirects to file:///d:/MyFolder/ContactUs.html and marks that as visited, not the path you are specifying.

So as said, either change your links to have file:/// in front, or use relative links (which makes more sense)