Skip to content
The Chat Archive
mistral-small-2506· Mistral AI LMArena Human Preference 140K

How to handle favicons properly

  1. User

    How to handle favicons properly

  2. Assistant

    Handling favicons properly ensures your website looks professional and provides a consistent experience across different devices and browsers. Here’s a step-by-step guide:

    1. Choose the Right Favicon Formats

    Modern websites should support multiple favicon formats for different devices and browsers:

    • .ico (Windows, IE, legacy support) – Traditional format, supports multiple sizes.
    • .png (Modern browsers, iOS, Android) – Recommended for high-quality icons.
    • .svg (Modern browsers, scalable) – Best for high-DPI displays (e.g., Retina).
    • .webp (Modern browsers, smaller file size) – Good for performance.

    2. Recommended Favicon Sizes

    Include multiple sizes to ensure compatibility:

    Size (px)Purpose
    16x16Default favicon (browser tab)
    32x32Windows taskbar, Android
    48x48Windows shortcuts
    64x64macOS, Linux
    96x96Android Chrome
    128x128iOS, Android
    180x180iOS (iPad, iPhone)
    192x192Android Chrome (PWA)
    256x256Windows 8/10 tiles
    512x512PWA, Android splash screens

    3. Place Favicon Files in the Root Directory

    Store favicons in the root (/) of your website (e.g., /favicon.ico, /favicon.png).

    4. Use HTML <link> Tags for Different Devices

    Add these to your <head> section:

    <!-- Standard favicon (16x16, 32x32) -->
    <link rel="icon" href="/favicon.ico" type="image/x-icon">
    
    <!-- PNG favicon (for modern browsers) -->
    <link rel="icon" href="/favicon.png" type="image/png" sizes="32x32">
    
    <!-- SVG favicon (scalable) -->
    <link rel="icon" href="/favicon.svg" type="image/svg+xml">
    
    <!-- Apple Touch Icon (iOS) -->
    <link rel="apple-touch-icon" href="/apple-touch-icon.png" sizes="180x180">
    
    <!-- Android Chrome (PWA) -->
    <link rel="manifest" href="/manifest.json">
    

    5. Create a Web App Manifest (for PWAs)

    If your site is a Progressive Web App (PWA), include a manifest.json:

    {
      "name": "Your Site",
      "short_name": "Site",
      "icons": [
        {
          "src": "/icons/icon-192x192.png",
          "sizes": "192x192",
          "type": "image/png"
        },
        {
          "src": "/icons/icon-512x512.png",
          "sizes": "512x512",
          "type": "image/png"
        }
      ],
      "start_url": "/",
      "display": "standalone",
      "theme_color": "#ffffff",
      "background_color": "#ffffff"
    }
    

    6. Test Your Favicon

    • Browser DevTools (Chrome/Firefox) → Check if favicon loads.
    • Real Devices (iOS, Android, Windows) → Verify appearance.
    • Online Tools (e.g., RealFaviconGenerator) → Generate and test favicons.

    7. Cache Control (Optional)

    To prevent caching issues, add HTTP headers:

    <FilesMatch "\.(ico|png|svg|webp)$">
      Header set Cache-Control "max-age=86400, public"
    </FilesMatch>
    

    8. Avoid Common Mistakes

    • Missing .ico → Some browsers (like IE) still require it.
    • Incorrect MIME types → Ensure image/x-icon for .ico and image/png for .png.
    • Large file sizes → Optimize favicons (use TinyPNG, SVGOMG).
    • No fallback → Always include at least .ico and .png.

    Final Checklist

    ✅ Multiple sizes (16x16, 32x32, 180x180, etc.) ✅ .ico, .png, and .svg formats ✅ Proper <link> tags in HTML ✅ manifest.json for PWAs ✅ Tested on multiple devices

    By following these steps, your favicon will display correctly across all platforms. 🚀

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.