Minimum Viable Favicon Code

前端 未结 1 1035
鱼传尺愫
鱼传尺愫 2021-02-05 07:57

I\'m confused about what\'s the simplest way to get favicons working on the majority of handsets and browsers.

1) Some sites suggest that it is enough to use:

         


        
相关标签:
1条回答
  • 2021-02-05 08:30

    The code in solution 3 is correct but outdated. Precomposed Touch icons were deprecated in iOS 7 and Android Chrome does not support 196x196 icons anymore, but 192x192 (it really won't use anything above 192x192; full disclosure: I'm the author of this article).

    So:

    <!-- For IE 9 and below. ICO should be 32x32 pixels in size -->
    <!--[if IE]><link rel="shortcut icon" href="/path/to/favicon.ico"><![endif]-->
    
    <!-- Touch Icons - iOS and Android 2.1+ 180x180 pixels in size. --> 
    <link rel="apple-touch-icon" href="/path/to/apple-touch-icon.png">
    
    <!-- Firefox, Chrome, Safari, IE 11+ and Opera. 192x192 pixels in size. -->
    <link rel="icon" href="/path/to/favicon.png">
    

    If you can place favicon.ico in the root of the web site, you can even skip its declaration, since IE looks for /favicon.ico by convention.

    0 讨论(0)
提交回复
热议问题