What is currently the best way to get a favicon to display in all browsers that currently support it?
Please include:
Which image formats are supported by which browsers.
Which lines are needed in what places for the various browsers.
What is currently the best way to get a favicon to display in all browsers that currently support it?
Please include:
Which image formats are supported by which browsers.
Which lines are needed in what places for the various browsers.
Having a favicon.*
in your root directory is automatically detected by most browsers. You can ensure it's detected by using:
<link rel="icon" type="image/png" href="/path/image.png" />
Personally I use .png images but most formats should work.
I use .ico format and put the following two lines within the <head>
element:
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
Favicon must be an .ico file to work properly on all browsers.
Modern browsers also support PNG and GIF images.
I've found that in general the easiest way to create one is to use a freely available web service such as favicon.cc.
It might also be worth including the 'favicons' for the iPhone here as well; that is if the user chooses to add your website to their home screen. The code used in this case is as follows:
<link rel="apple-touch-icon" href="touch.png" />
The dimensions should be 57x57 pixels. Alternatively you can omit the link tag and just put a file called 'apple-touch-icon.png' in the root directory of your website.
Just in case anyone is wondering how to create .ico files, there are several online tools that can help. A Google search will reveal many such tools:
Google search for: favicon creator
There is also a site where you can check how the favicon of any page is made
There you can see a tutorial about making favicons, image types and resolutions, it's nice!