当我在锚标签中给出绝对链接时,为什么访问的链接颜色没有改变? [英] Why is the visited link color not changing when I give the absolute link in anchor tag?
问题描述
我使用锚标记在 html 中创建了一个链接.我已经为 css 中的链接定义了一个未访问的颜色和一个访问的颜色,如下所示:
#menu{颜色:#000000;位置:绝对;底部:20px;右:30px;字体系列:Verdana、Arial、Helvetica、sans-serif;字体大小:10px;字体粗细:粗体;}#menu a:link{color:blue;}#menu a:visited{color:red;}
HTML 代码:
<a href=D:\MyFolder\ContactUs.html">联系我们</a>
当我在href"中给出相对地址时锚标签的属性,一切正常.
例如href = "ContactUs.html"
--因为它们在同一个文件夹中
但是当我在锚标记的 href
属性中给出绝对地址时,颜色并没有从蓝色"改变到红色"在访问页面时.它仍然是蓝色"仅.
例如href = "D:\MyFolder\ContactUs.html"
请解释为什么会这样?
请注意,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)
这篇关于当我在锚标签中给出绝对链接时,为什么访问的链接颜色没有改变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!