Html 网站图标未显示在 Google Chrome 中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21296044/
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
Website Icon Not Showing Up in Google Chrome
提问by Michael Yaworski
I've visited these questions and none of the answers worked for me:
我已经访问过这些问题,但没有一个答案对我有用:
Why doesn't my fav icon work in Chrome any more?
Chrome doesn't show the favicon
为什么我的收藏图标在 Chrome 中不再起作用?
Chrome 不显示网站图标
My Code
我的代码
My website is http://mikeyaworski.comand this is the code I use to set my icon:
我的网站是http://mikeyaworski.com,这是我用来设置图标的代码:
<head>
<title>mikeyaworski</title>
<link
rel="shortcut icon"
href="http://mikeyaworski.com/myicon.ico"
type="image/vnd.microsoft.icon"
>
</head>
This is my entire code.
这是我的全部代码。
What I've Tried
我试过的
Instead of
rel="shortcut icon"
I've triedrel="icon"
Instead of
type="image/vnd.microsoft.icon"
I've triedtype="image/x-icon"
Instead of
href="http://mikeyaworski.com/myicon.ico"
I've triedhref="myicon.ico"
而不是
rel="shortcut icon"
我试过rel="icon"
而不是
type="image/vnd.microsoft.icon"
我试过type="image/x-icon"
而不是
href="http://mikeyaworski.com/myicon.ico"
我试过href="myicon.ico"
The icon works in Mozilla and Internet Explorer. The icon does not work in Google Chrome. Any ideas?
该图标适用于 Mozilla 和 Internet Explorer。该图标在 Google Chrome 中不起作用。有任何想法吗?
采纳答案by Musa
Your html is invalid and your browser tries to fixit. In doing so your link tag ends up outside the head and is ignored, fix your html and it will work
您的 html 无效,您的浏览器会尝试修复它。这样做时,您的链接标签会在头部之外并被忽略,请修复您的 html,它会起作用
<!DOCTYPE>
<html>
<head>
<title>mikeyaworski</title>
<link rel="icon" href="myicon.ico" type="image/vnd.microsoft.icon">
</head>
<body> <!-- body tag should be here -->
<h1 style="text-align:center;font-family:trebuchet ms;" id="top"><br><br>Hompage</h1>
<p>
Coming soon. Until then, view my <a href="http://stackoverflow.com">StackOverflow</a> and other StackExchange profiles:
</p>
<a href="http://stackexchange.com/users/2644958">
<img src="http://stackexchange.com/users/flair/2644958.png?theme=dark" width="208" height="58" alt="profile for mike yaworski on Stack Exchange, a network of free, community-driven Q&A sites" title="profile for mike yaworski on Stack Exchange, a network of free, community-driven Q&A sites">
</a>
<body>
</html>
<!-- <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> -->
回答by Jatin
Try using the following code:
尝试使用以下代码:
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
Or Else have a go at the link below with similar discussion:
或者在下面的链接中进行类似的讨论:
local (file://) website favicon works in Firefox, not in Chrome or Safari- why?
本地(file://)网站图标在 Firefox 中有效,而不是在 Chrome 或 Safari 中-为什么?
Update: Or else give a following link a try: Fix missing favicons on Google Chrome
更新:或者尝试以下链接: Fix missing favicon on Google Chrome
Hope this helps. Thanks, Jatin
希望这可以帮助。谢谢,贾廷