A small set of files covers every browser and device: an SVG favicon, a favicon.ico fallback, an apple-touch-icon and a web app manifest. Here is the exact markup and sizes.
The short answer
#You do not need dozens of icon sizes. An SVG favicon, a favicon.ico fallback, a 180 by 180 pixel apple-touch-icon and a web app manifest with 192 and 512 pixel PNGs cover current browsers, home screens and installed apps.
_10<link rel="icon" href="/favicon.ico" sizes="32x32" />_10<link rel="icon" href="/icon.svg" type="image/svg+xml" />_10<link rel="apple-touch-icon" href="/apple-touch-icon.png" />_10<link rel="manifest" href="/manifest.webmanifest" />
Why it happens
#Different parts of the platform look for icons in different places:
- Browser tabs and bookmarks read
link rel="icon". If there is none, most browsers request/favicon.icofrom the site root. - iOS and iPadOS home screens use
apple-touch-icon. They ignore the manifest icons for this. - Android home screens and installed web apps read the icons listed in the web app manifest.
Old advice listed every size each device once used. Today browsers scale icons well, SVG favicons are supported in Chromium browsers, Firefox and, since Safari 26, Safari as well. The ICO file stays as a safety net for older browsers and tools that only ever request /favicon.ico.
How to fix it
#Create the files
Put these in the root of your public folder:
| File | Size | Used by |
|---|---|---|
favicon.ico | 32 by 32 | Older browsers, RSS readers, other tools |
icon.svg | Any | Modern browser tabs |
apple-touch-icon.png | 180 by 180 | iOS and iPadOS home screen |
icon-192.png | 192 by 192 | Android home screen |
icon-512.png | 512 by 512 | Android splash screen, install prompts |
Give the Apple icon a solid background and some padding. iOS fills transparent areas with black and rounds the corners itself.
Add the link tags
Put the link tags from the short answer in the head of every page. The sizes="32x32" on the ICO line stops Chromium choosing the ICO over the SVG.
Write the manifest
_17{_17 "name": "My Site",_17 "short_name": "My Site",_17 "icons": [_17 { "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" },_17 { "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" },_17 {_17 "src": "/icon-mask.png",_17 "type": "image/png",_17 "sizes": "512x512",_17 "purpose": "maskable"_17 }_17 ],_17 "theme_color": "#ffffff",_17 "background_color": "#ffffff",_17 "display": "standalone"_17}
The maskable icon is optional. Android crops it into a circle or rounded shape, so keep the logo inside the central 80 percent.
Support dark mode in the SVG
Because the SVG is a real document, it can carry its own media query. That lets a dark logo switch to a light one when the browser uses a dark theme.
_10<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">_10 <style>_10 path { fill: #111; }_10 @media (prefers-color-scheme: dark) {_10 path { fill: #fff; }_10 }_10 </style>_10 <path d="M4 4h24v24H4z" />_10</svg>
Support for the media query inside favicons varies, so pick colours that are still readable on both light and dark tab bars.
Using a framework
In the Next.js App Router you can drop favicon.ico, icon.svg and apple-icon.png into the app folder and it writes the tags for you. Other frameworks usually just serve files from a public folder, so the markup above works as is.
Common pitfalls
#- Seeing the old icon after a change. Browsers cache favicons hard. Rename the file or add a query string such as
icon.svg?v=2and do a hard reload. - Forgetting the ICO at the root. Some tools never read your
linktags. - Using a transparent PNG for
apple-touch-icon, which ends up on a black square. - Pointing to icons with relative paths like
icons/icon.svg. On nested pages they resolve to the wrong place; start them with a slash. - Detailed logos at 16 pixels. Simplify the mark for the favicon rather than shrinking the full logo.
Related reading
#Was this resource helpful?