Skip to content

Favicon guide

Dark mode favicons with SVG

A dark icon disappears on a dark tab bar, and a light one disappears on a light tab bar. An SVG favicon can carry its own CSS and switch colors to match the browser theme.

Updated November 11, 2026

The technique

SVG files can contain a <style> block, and browsers evaluate prefers-color-scheme inside it. Give the shapes a class and change their color in a media query:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
  <style>
    .mark { fill: #0c1a14; }
    @media (prefers-color-scheme: dark) {
      .mark { fill: #e6f4ec; }
    }
  </style>
  <path class="mark" d="M6 4h20v6H13v4h11v6H13v8H6z"/>
</svg>

Save that as favicon.svg and link it:

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

Things to know

  • It follows the operating system or browser theme, not your site's toggle. The media query inside the favicon can't see a dark mode class on your page.
  • Chrome, Edge, and Firefox support SVG favicons and the media query. Safari supports SVG favicons too. Test it in each browser you care about, because tab bar colors vary.
  • Keep the ICO as a fallback. Browsers that can't use the SVG fall back to favicon.ico, which has one fixed color, so pick colors for it that read on both light and dark.
  • Use outlines, not text. A <text> element depends on fonts installed on the visitor's machine. Convert letters to paths.

Often the simpler fix: a filled shape

If you don't want two color schemes, put your mark on a solid background shape (a rounded square or circle) in your brand color. A filled shape is visible on both light and dark tab bars without any media query. That's why most favicons you see are built that way. In FavMint you can preview your icon in light and dark tab mockups side by side to check.

Make your favicon in a minute

FavMint is a free favicon generator that runs in your browser. Design an icon from letters, symbols, or 2,100+ icons, check it at real sizes, and download the full package: favicon.ico, SVG, PNGs, the Apple touch icon, Android icons, and site.webmanifest. No signup, nothing uploaded.