audreyfeldroy /favicon-cheat-sheet
Obsessive cheat sheet to favicon sizes/types.
★ 9,903⑂ 396👁 258⑃ 44● 41▤ 0
+0
Daily
9,903
stars
396
forks
258
watchers
44
prs
41
issues
0
releases
README
favicon-cheat-sheet
A comprehensive cheat sheet to favicon sizes/types.
Modern Minimum (2024+)
For new projects, this covers 99% of use cases:
html
Dark mode support: Your SVG can adapt to light/dark mode. See SVG Favicons below.
Your manifest.json should include 192x192 and 512x512 icons for PWA support. That's it. Read on for legacy browser support and the full history.
---
SVG Favicons
Modern browsers support SVG favicons, which offer two key advantages: infinite scalability and the ability to respond to user preferences like dark mode.
Dark Mode Support
SVG favicons can contain embedded CSS, including media queries. This means your favicon can automatically adapt to the user's light or dark mode preference:
svg
.icon { fill: 1a1a1a; }
@media (prefers-color-scheme: dark) {
.icon { fill: ffffff; }
}
The prefers-color-scheme media query works inside the SVG file, so no JavaScript is needed. The browser handles the switch automatically when the user changes their system appearance.
Browser support: Chrome, Firefox, Edge, and Safari 15+ all support SVG favicons. The .ico fallback handles older browsers, which typically don't support dark mode system preferences anyway.
Tips:
- Keep your SVG simple. Complex gradients and filters add file size and can cause rendering issues at small sizes.
- Test both modes. What looks great in light mode might lose contrast in dark mode.
- Consider using currentColor if your SVG is simple enough, though explicit colors give you more control.
Safari Pinned Tab Icons (Safari 9-14)
Safari 9 through 14 used a separate "mask icon" for pinned tabs instead of the regular favicon. This requires a black-only SVG (no shades of gray or other colors) with a transparent background:
html
The color attribute defines the fill color when displayed. Safari 15+ uses the standard SVG favicon instead, so mask icons are only needed for legacy Safari support.
---
The HTML
Basics
For the main favicon itself, it's best for cross-browser compatibility not to use any HTML. Just name the file favicon.ico and place it in the root of your domain. [^1] [^2]
This works in every desktop browser/version all the way back to IE6, except for SeaMonkey. [^1]
Optional But Encouraged
You probably also want the following:
1. Touch icon for iOS 2.0+ and Android 2.1+:
html
2. IE 10 Metro tile icon (Metro equivalent of apple-touch-icon):
html
Replace FFFFFF with your desired tile color.
3. IE 11 Tile for Windows 8.1 Start Screen
html
ieconfig.xml
xml
FFFFFF
Legacy Browser Support
For older browsers and full platform coverage:
1. Largest to smallest apple-touch-icons [^3]:
html