How to add a favicon to your website?

A favicon is the small icon that shows up in the browser tab next to your page title.

There's a lot of old information out there about the favicon. In 2020 you don't need a `.ico` file. Here's what you need:

1. Resize your logo to be 32px by 32px
2. Save your logo as a png and name it favicon-32x32.png
3. Add the following line to your `<head>`
  <link rel="icon" href="favicon-32x32.png" />

That's it. If you are interested in more details you can keep reading.

Does my website need an icon?
Strictly speaking your site will work without one, but having an icon is critical for your user experience.

Why is a favicon important?
The icon is the main way that users will identify your site in their open browser tabs. It even shows up in search results so including an icon is important for SEO.

Is a single 32x32px icon enough?
32x32 is sufficient for simple use cases but if you're brand-conscious it will be a good idea to include a variety of sizes.

<link rel="icon" href="/favicon-16x16.png" sizes="16x16" />
<link rel="icon" href="/favicon-32x32.png" sizes="32x32" />
<link rel="icon" href="/favicon-48x48.png" sizes="48x48" />
<link rel="icon" href="/favicon-192x192.png" sizes="192x192" />

Finally, as a backup you should also include a `favicon.ico` available at the root of your domain which supports the 16x16 format. This is only necessary for very old browsers (less than 1% of your total traffic), so I generally don't do this except for sites which need that compatibiltiy.

Does that list include all favicon sizes?
No. The full list is long and ill-defined. There are a large number of specialized use cases for which a system might choose to use a specific icon size if available. The small list above will cover virtually all important use cases.

How to create a good favicon?
Your favicon should represent your brand and be distinctive and scalable. Avoid too much detail. Manually edit your low-resolution icons (ex: 16x16px) after rescaling so you don't end up with a blurry blog of a logo (make sure the critical features of the image have distinct boundaries). That's why it's important to explicitly define a 16x16 icon - so you can control how it looks when scaled down.

Can I change my favicon dynamically?
Yes, you can change your favicon to help represent page status. The most common example of this is to show notifications such as an unread message count. This can help capture the user's attention and bring them back to your page, but use sparingly because most users do not appreciate this unless the notifications are actually important to them.. The simplest way to do this is to give your favicon an id attribute so you can find it and change the href attribute in-place.

If you're going to include dynamic favicons, you're probably better off only using the 32x32px variant to avoid handling too many different cases.


Much of the information you'll see about this topic is likely outdated, but hopefully this guide helped clarify that.

When in doubt, a single 32px square png is plenty:

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