为favicon.ico添加链接标签是必要的吗? [英] Necessary to add link tag for favicon.ico?
问题描述
是否有任何现代浏览器不会自动检测到favicon.ico?是否有理由为favicon.ico添加链接标记?
Are there any modern browsers that won't detect the favicon.ico automatically? Is there any reason to add the link tag for favicon.ico?
<link rel="shortcut icon" href="/favicon.ico">
我的猜测是,如果您决定使用GIF,只需将它包含在HTML文档中或PNG ...
My guess is that it's only necessary to include it in the HTML document if you decide to go with GIF or PNG...
推荐答案
选择不同的位置或文件类型(例如 PNG 或 SVG )的favicon:
一个原因可能是你想要在特定位置的图标,也许在图像文件夹或类似的东西。例如:
To choose a different location or file type (e.g. PNG or SVG) for the favicon:
One reason can be that you want to have the icon in a specific location, perhaps in the images folder or something alike. For example:
<link rel="icon" href="_/img/favicon.png">
这个不同的位置甚至可能是一个CDN,就像SO似乎对< link rel =shortcut iconhref =http://cdn.sstatic.net/stackoverflow/img/favicon.ico>
。
This diferent location may even be a CDN, just like SO seems to do with <link rel="shortcut icon" href="http://cdn.sstatic.net/stackoverflow/img/favicon.ico">
.
要详细了解如何使用PNG等其他文件类型,请查看此问题。
To learn more about using other file types like PNG check out this question.
用于缓存清除用途:
将查询字符串添加到缓存清除目的的路径中: / p>
For cache busting purposes:
Add a query string to the path for cache-busting purposes:
<link rel="icon" href="/favicon.ico?v=1.1">
Favicons的缓存非常多,这是一种确保刷新的好方法。
Favicons are very heavily cached and this a great way to ensure a refresh.
关于默认位置的脚注:
至于问题的第一位:全部现代浏览器会在默认位置检测到图标,因此 不是使用链接
的理由。
脚注 rel =icon
:
如 @ Semanino的回答所示,使用 rel =快捷图标 code>是老版本的Internet Explorer所需的旧技术,但在大多数情况下可以用更正确的
rel =icon
指令替换。 基于此的文章@Semanino 正确链接到相应的规范,其中显示 rel
的值快捷键
不是有效的选项。
Footnote about rel="icon"
:
As indicated by @Semanino's answer, using rel="shortcut icon"
is an old technique which was required by older versions of Internet Explorer, but in most cases can be replaced by the more correct rel="icon"
instruction. The article @Semanino based this on properly links to the appropriate spec which shows a rel
value of shortcut
isn't a valid option.
这篇关于为favicon.ico添加链接标签是必要的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!