Grabbing a favicon from any website

05 May 2012

One of the great discoveries I made this week relates to grabbing a favicon from any website as required; Google has put together a handy API which takes in a URL, and outputs a PNG 16x16 image of the site's favicon. This has the potential to be very handy for something. I'm not 100% sure what I'm going to use it for, but I'm going to use it for something!

An example of this is:

<img src="http://www.google.com/s2/u/0/favicons?domain_url=http://google.com">

Which outputs .

For a full demo of this head over the snippet page.


Update: I've thrown together a JS Fiddle demoing a possible use for this. If anyone can work out a method of getting url() and attr() to concatinate nicely I will be a very happy person! I've got a demo of what I'm after using JavaScript, but I'm quite keen to have a CSS only method of achieving this!

Back to all posts