HTML Favicon Implementation

HTML Favicon

Master favicon implementation with comprehensive coverage of formats, sizes, platform support, and modern PWA requirements for professional web branding.

How do you add a favicon to a website?

Put the icon file in your site and link it from the <head>: <link rel="icon" href="/favicon.ico" sizes="32x32">. A modern minimal set is a 32×32 favicon.ico, an SVG icon for modern browsers, and a 180×180 apple-touch-icon.png for iOS home screens.

<link rel="icon" href="/favicon.ico" sizes="32x32">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="manifest" href="/manifest.webmanifest">

Favicon Essentials

Favicons are small icons that represent your website in browser tabs, bookmarks, and mobile home screens. Modern favicon implementation requires multiple formats and sizes to support all platforms and use cases.

Browser Support

  • ICO format: Legacy browser support
  • PNG format: Modern browsers
  • SVG format: Scalable vector icons

Mobile Platforms

  • Apple Touch: iOS home screen icons
  • Android Chrome: PWA app icons
  • Windows tiles: Start menu integration

Advanced Features

  • Dynamic icons: JavaScript updates
  • Theme adaptation: Dark mode support
  • Notifications: Badge overlays

Basic Favicon Setup

Essential Favicon Links

Legacy ICO

<link rel="icon" href="/favicon.ico">

Modern PNG

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

SVG Scalable

<link rel="icon" type="image/svg+xml" href="/favicon.svg">

Apple Touch

<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">

Required Favicon Sizes

Browser Tabs
  • 16x16 (small tabs)
  • 32x32 (standard)
  • 48x48 (high-res)
Mobile Icons
  • 120x120 (iPhone)
  • 152x152 (iPad)
  • 180x180 (iPhone Plus)
PWA & Android
  • 192x192 (standard)
  • 384x384 (high-res)
  • 512x512 (splash screen)

Complete Favicon Implementation

Comprehensive favicon setup covering all platforms, formats, PWA requirements, and advanced features including dynamic updates and theme adaptation.

Code Editor

<!-- These go in <head>. The browser shows them in the tab. -->
<link rel="icon" href="/favicon.ico" sizes="32x32">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">

<p>An SVG favicon can be drawn inline:</p>
<svg width="64" height="64" viewBox="0 0 32 32"><rect width="32" height="32" rx="6" fill="#2563eb"/><text x="16" y="22" font-size="18" text-anchor="middle" fill="white" font-family="sans-serif">C</text></svg>
<ul id="icons"></ul>

Preview

PWA & Mobile Integration

Web App Manifest

{ "name": "My Web App", "short_name": "MyApp", "start_url": "/", "display": "standalone", "background_color": "#ffffff", "theme_color": "#2563eb", "icons": [ { "src": "/icon-192x192.png", "sizes": "192x192", "type": "image/png", "purpose": "any maskable" } ] }

Apple Meta Tags

  • apple-mobile-web-app-capable: Standalone mode
  • apple-mobile-web-app-title: App name
  • apple-mobile-web-app-status-bar-style: Status bar color
  • apple-touch-icon: Home screen icon

Windows Integration

  • msapplication-TileColor: Tile background
  • msapplication-TileImage: Start menu tile
  • msapplication-config: Browser config XML
  • msapplication-starturl: Launch URL

Advanced Features

  • Dynamic updates: JavaScript favicon changes
  • Notification badges: Unread count display
  • Theme adaptation: Light/dark mode icons
  • Loading states: Animated progress indicators

Favicon Best Practices

Design Guidelines

  • • Keep designs simple and recognizable at small sizes
  • • Use high contrast colors for visibility
  • • Avoid fine details that disappear when scaled
  • • Test icons at different sizes and backgrounds
  • • Consider both light and dark theme variants
  • • Maintain consistency with your brand identity

Technical Requirements

  • • Use square aspect ratios (1:1)
  • • Provide multiple sizes for different contexts
  • • Optimize file sizes without quality loss
  • • Include fallback formats for compatibility
  • • Use appropriate MIME types in link tags
  • • Test across different browsers and devices

Performance Tips

  • • Use SVG for scalable, small-file-size icons
  • • Compress PNG files with tools like TinyPNG
  • • Consider WebP format for supported browsers
  • • Use preload hints for critical favicon files
  • • Host icons on CDN for faster delivery
  • • Implement proper caching headers

Common Mistakes

  • • Using only one favicon size or format
  • • Forgetting mobile platform requirements
  • • Not testing on actual devices
  • • Using low-quality or pixelated images
  • • Missing web app manifest for PWAs
  • • Ignoring accessibility considerations

HTML Favicons — step by step

1 / 4
1

Add a basic favicon

Link a favicon in the head element with link rel='icon' href='/favicon.ico'. Modern browsers also support PNG and SVG favicons. Use link rel='icon' type='image/png' for PNG files and link rel='icon' type='image/svg+xml' for SVG.

1 of 4
💡Use a Web App Manifest for the Full Icon Set
Instead of adding multiple link tags for every icon size, declare all icons in a Web App Manifest (manifest.json) with a single link rel='manifest' tag. This covers Android home screen icons, splash screens, and PWA installation icons in one place.

🎯 Quick Check

Which favicon size is typically required for Apple iOS home screen icons?

Favicon Implementation Complete!

Excellent! You've mastered favicon implementation with comprehensive platform support, PWA integration, and advanced features. Ready to explore responsive image techniques?

HTML Favicon: summary

Key points

  • Browsers request /favicon.ico automatically, so keep one at the site root.
  • SVG favicons can switch for dark mode with a prefers-color-scheme media query inside the SVG.
  • Browsers cache favicons aggressively; test changes in a private window.
  • Google shows your favicon in mobile search results, so make it clear at 48×48.

Frequently asked questions

›Why is my favicon not showing?

Check the path, then hard-refresh or use a private window, because favicons are heavily cached. Also make sure the file is a real image of the declared type.

›What size should a favicon be?

32×32 for the .ico, any size for SVG, 180×180 for the Apple touch icon, and 192×192 and 512×512 in the web manifest for Android and PWAs.