SVG Favicon with Dark Mode: How to Add Adaptive Theme Icons Using CSS
To support dark mode in favicons, embed an internal <style> block inside an SVG file using @media (prefers-color-scheme: dark). When the operating system or browser theme switches to dark mode, the SVG fill and stroke adjust automatically without JavaScript.
Check favicons on any website
Install the FetchFavicon Chrome Extension to extract, preview, and validate favicons instantly.
Vector SVG favicons allow modern browsers to adapt tab icons dynamically to user system preferences. By incorporating CSS media queries directly into the SVG file, you can deliver crisp, contrast-optimized graphics for light and dark operating system themes using a single lightweight asset.
The core technique relies on embedding a <style> block within the root <svg> element. Inside this block, standard CSS declarations define base colors, while an @media (prefers-color-scheme: dark) query overrides colors whenever the user activates dark mode.
Here is the standard production SVG dark mode pattern: embed <style> inside your SVG with path rules for default and dark themes. Modern browsers like Chrome, Edge, Firefox, and Safari 15+ evaluate this style block natively against the host OS theme.
While modern desktop and mobile browsers fully support SVG favicons with theme detection, legacy browsers and search engine bots still expect a fallback. Always provide a multi-resolution favicon.ico containing 16, 32, and 48-pixel bitmaps alongside your SVG definition in your HTML <head>.
Before deploying your adaptive icons, optimize your vector markup with our SVG Optimizer, and verify rendering across light and dark tab bars using the Favicon Preview tool. You can also generate your legacy ICO fallback with our SVG to ICO converter.
How it works
- 1
Create a clean square SVG asset
Design your vector icon with a square viewBox (e.g., 0 0 100 100) and ensure shapes use CSS fill and stroke classes rather than hardcoded presentation attributes.
- 2
Add internal CSS media query
Embed an internal <style> block inside the SVG defining default light theme colors and an @media (prefers-color-scheme: dark) rule targeting dark mode fills.
- 3
Link SVG and ICO in HTML <head>
Declare both <link rel="icon" href="/favicon.ico" sizes="any"> and <link rel="icon" href="/favicon.svg" type="image/svg+xml"> to guarantee universal browser compatibility.
Platform Dimension Specifications & Compression Benchmark
Standard dimension requirements across search engines, mobile OS, and WebAssembly Oxipng lossless byte reduction.
| Target Platform / OS | Required Dimensions | Format & Delivery | Oxipng Wasm Weight | Byte Savings |
|---|---|---|---|---|
| Google Search SERP | 48Γ48 px (multiples of 48) | .ico, .png | 4.6 KB | -68.9% |
| Apple iOS / iPadOS Safari | 180Γ180 px | .png (apple-touch-icon) | 14.8 KB | -67.9% |
| Android Chrome & PWA | 192Γ192 px & 512Γ512 px | .png (site.webmanifest) | 59.1 KB | -69.3% |
| Windows Edge & Desktop | 16Γ16, 32Γ32, 48Γ48 px | Multi-resolution .ico | 8.8 KB | -69.5% |
| Legacy Web Browsers | 32Γ32 px / 16Γ16 px | .ico (/favicon.ico) | 3.1 KB | -67.0% |
* Benchmark measurements based on lossless RGBA Oxipng WebAssembly compression executing locally in modern web browsers.
Try it now
Convert and test your dark mode SVG favicon
SVG to ICO ConverterFAQ
How does dark mode work in an SVG favicon?+
An SVG favicon uses an internal <style> tag containing @media (prefers-color-scheme: dark). The browser rendering engine evaluates this media query against the operating system theme and updates the vector styles automatically without JavaScript or page reloads.
Which browsers support SVG favicons with dark mode?+
All major modern desktop and mobile browsers support SVG favicons and CSS prefers-color-scheme queries, including Google Chrome 80+, Mozilla Firefox, Microsoft Edge, and Apple Safari 15+.
Do I still need a standard favicon.ico if I use an SVG favicon?+
Yes. Search engine web crawlers, legacy browsers, Windows taskbar shortcuts, and certain RSS readers only recognize traditional favicon.ico files. Always link both: the SVG for modern displays and the ICO for legacy fallbacks.
Why is my SVG dark mode favicon not switching themes?+
Common issues include external CSS stylesheet links (SVG favicons must use inline <style> blocks), aggressive browser icon caching requiring a forced hard reload (Ctrl+F5) or cache-busting query parameter (?v=2), or missing viewBox coordinates.