I am building a linklist, that automatically retrieves favicons of linked sites and displays them next to them. Now, I noticed, that some sites (e.g. this very one, doctype.org) don't have a favicon.ico in their root directory. Yet the browser shows an icon next to the URL.

I thought this was a de facto standard, having the favicon in the root directory. What are the advantages of cloaking it? And how is it done? (Just asking out of interest).

4 answers


It's not cloaking, it's the proper way to do it.

Putting a .ico file in the root isn't a good way to do a fundamental part of a website because:

  1. It's not a well known format (no registered MIME type)
  2. Assuming content is always in the same place is against the ideas set forward in the Architecture of the World Wide Web
  3. The format that was put forward to describe it's position didn't follow the spec

The proper way is to put in the head of the page code like:


<link rel="icon" type="image/vnd.microsoft.icon" href="http://example.com/image.ico">
<link rel="icon" type="image/png" href="http://example.com/image.png">
<link rel="icon" type="image/gif" href="http://example.com/image.gif">


<link rel="icon" type="image/vnd.microsoft.icon" href="/somepath/image.ico" />
<link rel="icon" type="image/png" href="/somepath/image.png" />
<link rel="icon" type="image/gif" href="/somepath/image.gif" />

This specifies it's the icon, has the MIME type (note that ico has the vendor prefix as it's not standard), and then the path.

By parsing the href section of the link with rel = icon, you will be able to get the favicon more correctly.

Answered about 8 years ago by Rich Bradshaw

It is still a good idea to have the icon at /favico.ico, otherwise 404 responses to requests for that file will constitute 95% off your error log (or to put it another way, your error logs will be much bigger than they need to be).

Internet Explorer requests favicon.ico for every page request it sends, and has no way of turning that off. Opera requests it by default but you can disable it. I'm not sure about Firefox, Safari, Chrome etc.

Answered about 8 years ago by Richard Grevers
  • Or symlink it to your real file for backward compatability. Rich Bradshaw about 8 years ago
Aziz 10

if you checked the source of doctype.com, you'll find:

<link rel="icon" type="image/png" href="/images/favicon.png?1" />

which is used to specify the favicon.

More info in wikipedia

Answered about 8 years ago by Aziz
Tilman 0

Ok, yes, but why not just use .ico and put it in the root? Is there any advantage to that? (Sorry, I was stupid, didn't even think of checking the source o_O... )

Answered about 8 years ago by Tilman
  • even de facto standards aren't adhered to by everyone ;) there's no reason to put it in the root or in any folder, different people/companies organise their content differently danwellman about 8 years ago
  • I seem to remember in this case it was a traffic thing. Moving it off to a CDN seems excessive, but it worked. See http://twitter.com/codinghorror/status/3379760298 Olly Hodgson about 8 years ago
  • On a server environment it can happen, that the root is anywhere on the server and not under control of the people running a site. Especially if the site works with different db-layers, a templating mechanism,..... vikingosegundo about 8 years ago