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">
My guess is that it's only necessary to include it in the HTML document if you decide to go with GIF or PNG...
It all depends on which format of image you like to use!
if you have a icon of your website, it will be much better for UX!
We can add for all devices with platform specific size
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:
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">
.To learn more about using other file types like PNG check out this question.
For cache busting purposes:
Add a query string to the path for cache-busting purposes:
Favicons are very heavily cached and this a great way to ensure a refresh.
Footnote about default location:
As far as the first bit of the question: all modern browsers would detect a favicon at the default location, so that's not a reason to use a
link
for it.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 correctrel="icon"
instruction. The article @Semanino based this on properly links to the appropriate spec which shows arel
value ofshortcut
isn't a valid option.Please note that both the HTML5 specification of W3C and WhatWG standardize
Note the value of the "rel" attribute!
The value
shortcut icon
for therel
attribute is a very old Internet Explorer specific extension and deprecated.So please consider not using it any more and updating your files so they are standards compliant and are displayed correctly in all browsers.
You might also want to take a look at this great post: rel="shortcut icon" considered harmful
The bottom line is not all browsers will actually look for your favicon.ico file. Some browsers allow users to choose whether or not it should automatically look. Therefore, in order to ensure that it will always appear and get looked at, you do have to define it.