{"id":306644,"date":"2020-04-24T07:58:29","date_gmt":"2020-04-24T14:58:29","guid":{"rendered":"https:\/\/css-tricks.com\/?p=306644"},"modified":"2022-02-08T17:10:12","modified_gmt":"2022-02-09T01:10:12","slug":"svg-favicons-and-all-the-fun-things-we-can-do-with-them","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/svg-favicons-and-all-the-fun-things-we-can-do-with-them\/","title":{"rendered":"SVG, Favicons, and All the Fun Things We Can Do With Them"},"content":{"rendered":"\n
Favicons are the little icons you see in your browser tab. They help you understand which site is which when you\u2019re scanning through your browser\u2019s bookmarks and open tabs. They\u2019re a neat part of internet history that are capable of performing some cool tricks<\/a>.<\/p>\n\n\n\n One very new trick is the ability to use SVG as a favicon. It\u2019s something that most modern browsers support<\/a>, with more support on the way.<\/p>\n\n\n\n\n\n\n\n Here\u2019s the code for how to add favicons to your site. Place this in your website’s And place this code in your site’s web app manifest<\/a>:<\/p>\n\n\n\n Browsers that do<\/strong> support SVG favicons will override the first link element declaration and honor the second instead. Browsers that do not<\/strong> support SVG favicons but do<\/strong> support web app manifests will use the higher-resolution images. All other browsers fall back to using the You may also notice the alternate attribute value for our Following the favicons is a line of code that loads another SVG image, one called Here\u2019s more detail on the current level of SVG favicon support:<\/p>\n\n\n This browser support data is from Caniuse<\/a>, which has more detail. A number indicates that browser supports the feature at that version and up.<\/p><\/div><head><\/code>:<\/p>\n\n\n\n
<link rel=\"icon\" href=\"\/favicon.ico\" sizes=\"any\">\n<link rel=\"icon\" href=\"\/favicon.svg\" type=\"image\/svg+xml\">\n<link rel=\"manifest\" href=\"\/manifest.webmanifest\"><\/code><\/pre>\n\n\n\n
{\n \"icons\": [\n { \"src\": \"\/icon-192.png\", \"type\": \"image\/png\", \"sizes\": \"192x192\" },\n { \"src\": \"\/icon-512.png\", \"type\": \"image\/png\", \"sizes\": \"512x512\" }\n ]\n}<\/code><\/pre>\n\n\n\n
favicon.ico<\/code> file. This ensures that all<\/strong> browsers that support favicons can enjoy the experience.\u00a0<\/p>\n\n\n\n
rel<\/code> declaration<\/a> in the second line. This programmatically communicates to the browser that the favicon with a file format that uses
.ico<\/code> is specifically used as an alternate presentation.<\/p>\n\n\n\n
safari-pinned-tab.svg<\/code>. This is to support Safari\u2019s pinned tab functionality<\/a>, which existed before other browsers had SVG favicon support. There\u2019s additional files you can add here to enhance your site for different apps and services, but more on that in a bit.<\/p>\n\n\n\n
Desktop<\/h4>