Correct MIME Type for favicon.ico?

后端 未结 3 387
旧时难觅i
旧时难觅i 2021-01-30 05:03

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

E.g

3条回答
  •  长情又很酷
    2021-01-30 05:31

    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:

    
    
    
    
    

    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 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.

提交回复
热议问题