favicon支持的圖片格式


為網站設置favicon有兩種方式:

1、網站根目錄下放置名為favicon.ico的圖片,瀏覽器就會自動獲取;

2、在頁面中通過<link rel="shortcut icon"  href="http://example.com/myicon.ico" />.

 

對於favicon來說,一般都是使用ico格式,不過對於根目錄的favicon圖片chrome、firefox、IE11等現代瀏覽器都支持PNG、GIF(無動畫)格式。對於通過link來設置的favicon格式,IE7+、現代瀏覽器都支持PNG、GIF格式,不過在IE7下圖片效果會很差。

對於蘋果設備,我們可以通過在head里寫入<link rel="apple-touch-icon" href="somepath/image.png" />、<link rel="apple-touch-icon-precomposed" href="somepath/image.png" />來設置。

 

  Google Chrome Internet Explorer Firefox Opera Safari
<link rel="shortcut icon"
 href="http://example.com/myicon.ico" />
Yes[4] Yes[4][19] Yes[4] Yes[4] Yes
<link rel="icon"
 href="http://example.com/image.ico" />
Yes Yes (from IE 11)[20] Yes Yes Yes
<link rel="icon"
 type="image/vnd.microsoft.icon"
 href="http://example.com/image.ico" />
Yes Yes (from IE 9)[20] Yes Yes Yes
<link rel="icon" type="image/png"
 href="http://example.com/image.png" />
Yes Yes (from IE 11)[20] Yes Yes Yes
<link rel="icon" type="image/gif"
 href="http://example.com/image.gif" />
Yes Yes (from IE 11)[20] Yes Yes Yes
<link rel="icon" type="image/x-icon"
href="http://example.com/image.ico"/>
Yes[4] Yes (from IE 9)[26] Yes[4] Yes[4] Yes
favicon.ico located in the website's root Yes Yes Optional[27] Optional[28] Yes
precedence: prefer root or (X)HTML linked version linked[22] linked[22] linked[22] ? ?

 

參考文檔:

http://en.wikipedia.org/wiki/Favicon

http://msdn.microsoft.com/en-us/library/ms537656(v=vs.85).aspx

http://stackoverflow.com/questions/1344122/favicon-png-vs-favicon-ico-why-should-i-use-pngs-instead-of-icos

http://www.webmasterworld.com/html/3701134.htm

http://blogs.msdn.com/b/ieinternals/archive/2013/09/08/internet-explorer-favicons-png-link-rel-icon-caching.aspx

http://blogs.msdn.com/b/jeffdav/archive/2007/03/01/why-doesn-t-the-favicon-for-my-site-appear-in-ie7.aspx


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM