Html 图标不工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11362968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Favicon not working
提问by th3w01f98
My favicon that I am trying to insert into my webpage is not working. Can someone tell me the code and styling I need to insert it?
我试图插入到我的网页中的收藏夹图标不起作用。有人可以告诉我需要插入的代码和样式吗?
<html>
<head>
<title>Welcome to Crash - Login or Signup</title>
<link rel="stylesheet" type="text/css" href="crash_styling.css"></link>
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
</head>
<body link="#336666" alink="red" vlink="red">
<div id="header_title">
<h1 id="title">crash</h1>
<p id="motto">Keep track of all your assignments and projects.</p>
</div>
<form name="input" action="html_form_action.asp" method="get" id="user_passEntry">
Username:<input type="text" name="username" placeholder="Your Username" /> <br />
Password:<input type="password" name="password" placeholder="Your Password" />
<input type="submit" value="submit">
</form>
<p id="description">Crash is a way students can keep track of their projects and assignments on the computer or on their devices. With crash, you can be sure you'll never turn in something late again.</p>
<div class="make"><a href="crash_styling" style="text-decoration:none"/>Make a New Assignment</div>
<div class="edit"><a href="crash_styling" style="text-decoration:none"/>Edit an Assignment</div>
<div class="check"><a href="crash_styling" style="text-decoration:none"/>Check off an Assignment</div>
</body>
</html>
回答by Taryn
To place a Favicon on your site you would use the following in the <head>
tag
要在您的网站上放置 Favicon,您可以在<head>
标签中使用以下内容
<link rel="shortcut icon" href="http://yourwebsitepath/favicon.ico" />
You need to be sure that the path is correct for the icon. If the path is not correct it will not appear. I have also seen caching issues that makes it seem that the icon isn't working. Always try to restart your browser after clearing the cache.
您需要确保图标的路径正确。如果路径不正确,它将不会出现。我还看到了缓存问题,这使得图标似乎不起作用。清除缓存后,请务必尝试重新启动浏览器。
回答by Simon Dorociak
Most likely you have a bad pathto your icon. Confirm your file path. Try to use
很可能你的图标路径不好。确认您的文件路径。尝试使用
href="favicon.ico"
instead of
代替
href="/favicon.ico"
maybe it will work. Or if you have icon in some folderfor example in images
也许它会起作用。或者,如果您在某个文件夹中有图标,例如在图像中
href="images/favicon.ico"
You doing it right but if you will have bad path, iconwon't appear.
你做对了,但如果你的路径不好,图标就不会出现。
So your CSS
works and if your iconis on same levellike CSS
file so remove /
and it should work.
所以你的CSS
作品,如果你的图标与文件处于同一级别,CSS
那么删除/
它应该可以工作。