160

According to the Internet Assigned Numbers Authority (IANA), all .ico file falls under the MIME type image/vnd.microsoft.icon. (Source)

E.g. <link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico" />

However, savvy internet guru, Paul Irish, claims this is wrong, and that it would actually be image/x-icon. (Source)

E.g. <link rel="icon" type="image/x-icon" href="favicon.ico" />

I know you can get away with not including a "type" for .ico files, but if you were going to include one, which should it be? Are there actually any problems with serving it as official IANA type?

Chuck Le Butt
  • 43,669
  • 58
  • 179
  • 268
  • Note of caution: `favicon.ico` files might not be true ".ico" files. My corporate site uses a png (named "favicon.ico") and serves it with the "image/png" type. Serving it with either of the ".ico" types mentioned here were BOTH wrong, as it caused the browser to misinterpret! – Dan H Apr 23 '18 at 13:35

3 Answers3

196

When you're serving an .ico file to be used as a favicon, it doesn't matter. All major browsers recognize both mime types correctly. So you could put:

<!-- IE -->
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<!-- other browsers -->
<link rel="icon" type="image/x-icon" href="favicon.ico" />

or the same with image/vnd.microsoft.icon, and it will work with all browsers.

Note: There is no IANA specification for the MIME-type image/x-icon, so it does appear that it is a little more unofficial than image/vnd.microsoft.icon.

The only case in which there is a difference is if you were trying to use an .ico file in an <img> tag (which is pretty unusual). Based on previous testing, some browsers would only display .ico files as images when they were served with the MIME-type image/x-icon. More recent tests show: Chromium, Firefox and Edge are fine with both content types, IE11 is not. If you can, just avoid using ico files as images, use png.

mata
  • 60,113
  • 7
  • 139
  • 148
  • I didn't choose anything anywhere, I tried to explain the two usecases: 1 - used as favicon (doesn't matter which mime type), 2 - used as an img within webpage (IE only displays it correctly with mimetype image/x-icon). – mata Apr 07 '13 at 19:01
  • You say, you can use .ico files in `` provided they are served as **image/x-image** by the webserver. You then say if you're going to use .ico files as images in HTML pages you should set the MIME type to **image/x-icon**. – Chuck Le Butt Apr 12 '13 at 15:00
  • Great. At least it makes sense now! I'm not really interested in serving .ico files as images within a website, though. The question is specifically about using .ico file as favicons. If you rephrase your answer, that would be much more helpful. Thanks. – Chuck Le Butt Apr 12 '13 at 15:08
  • According to wikipedia, image/x-icon was just made up by Microsoft, image/vnd.microsoft.icon is registered with IANA (but not registered by Microsoft themselves). – mjaggard Jan 17 '14 at 15:45
  • 12
    FWIW, Google uses image/x-icon for their [favicon](http://www.google.com/favicon.ico). – NateS Jan 24 '14 at 12:25
  • Thank you! Probably the best answer – Anton Semenichenko Jun 11 '18 at 13:31
36

I think the root for this confusion is well explained in this wikipedia article.

While the IANA-registered MIME type for ICO files is image/vnd.microsoft.icon, it was submitted to IANA in 2003 by a third party and is not recognised by Microsoft software, which uses image/x-icon instead.

If even the inventor of the ICO format does not use the official MIME type, I will use image/x-icon, too.

Jürgen Steinblock
  • 26,572
  • 21
  • 100
  • 169
  • 4
    Finally an answer! However it's still the IANA-registered MIME type... even if Microsoft themselves don't use it. Weird. – Chuck Le Butt Feb 09 '15 at 19:22
4

I have noticed that when using type="image/vnd.microsoft.icon", the favicon fails to appear when the browser is not connected to the internet. But type="image/x-icon" works whether the browser can connect to the internet, or not. When developing, at times I am not connected to the internet.

mega6382
  • 8,624
  • 16
  • 43
  • 65
kmcc
  • 49
  • 1