更新时间:2023-12-03 09:46:10
请注意,css 类用于 visited
而非 clicked
.
所以当你点击<a href="D:\MyFolder\ContactUs.html">联系我们</a>
并且浏览器自动检测到它是一个文件时,它重定向到 file:///d:/MyFolder/ContactUs.html
并将其标记为已访问,而不是您指定的路径.
如前所述,要么将链接更改为 file:///
前面,要么使用相对链接(这更有意义)
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 :
#menu{
color:#000000;
position:absolute;
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>
</div>
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)