How can I get a web site's favicon?

The Solution to How can I get a web site's favicon? is

You'll want to tackle this a few ways:

  1. Look for the favicon.ico at the root of the domain

  2. Look for a <link> tag with the rel="shortcut icon" attribute

    <link rel="shortcut icon" href="/favicon.ico" />

  3. Look for a <link> tag with the rel="icon" attribute

    <link rel="icon" href="/favicon.png" />

The latter two will usually yield a higher quality image.

Just to cover all of the bases, there are device specific icon files that might yield higher quality images since these devices usually have larger icons on the device than a browser would need:

<link rel="apple-touch-icon" href="images/touch.png" />

<link rel="apple-touch-icon-precomposed" href="images/touch.png" />

And to download the icon without caring what the icon is you can use a utility like which will do all of the heavy lifting:

var client = new System.Net.WebClient();


~ Answered on 2011-02-25 15:30:25

Most Viewed Questions: