{"id":71569,"date":"2026-11-23T13:32:00","date_gmt":"2026-11-23T08:02:00","guid":{"rendered":"https:\/\/www.quickonlinetips.com\/archives\/?p=71569"},"modified":"2026-11-22T16:53:27","modified_gmt":"2026-11-22T11:23:27","slug":"favicon-dark-light-mode","status":"publish","type":"post","link":"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/","title":{"rendered":"Favicon for Dark Mode and Light Mode: How to Make One Icon Work on Both"},"content":{"rendered":"<p>A favicon that looks great on a white browser tab can almost disappear on a dark one. A black logo on a transparent background turns into a dark smudge when someone uses dark mode, and a white logo vanishes in light mode. The fix is a favicon for dark mode and light mode that switches on its own, and you can do it with one file. Here&#8217;s how it works in HTML and in WordPress, which browsers support it, and what to do for the ones that don&#8217;t.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-71565\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-favicon-dark-light-mode.png\" alt=\"The same star favicon shown dark on a light browser tab and white on a dark browser tab\" width=\"2400\" height=\"1260\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-favicon-dark-light-mode.png 2400w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-favicon-dark-light-mode-300x158.png 300w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-favicon-dark-light-mode-1024x538.png 1024w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-favicon-dark-light-mode-150x79.png 150w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-favicon-dark-light-mode-768x403.png 768w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-favicon-dark-light-mode-1536x806.png 1536w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-favicon-dark-light-mode-2048x1075.png 2048w\" sizes=\"(max-width: 2400px) 100vw, 2400px\" \/><\/p>\n<blockquote><p><strong>Quick answer:<\/strong> Make one SVG favicon with a small CSS rule inside it: <code>@media (prefers-color-scheme: dark)<\/code> changes the colours, or swaps a dark-mode drawing for a light one. Link it as an extra icon after your normal PNG or ICO icons. Chrome, Edge and Firefox then switch it automatically with the browser&#8217;s theme. Safari shows the SVG but stays on the light version, so pick light colours that still read on a dark tab, or keep a backing shape behind the icon.<\/p><\/blockquote>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_90 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6b0413afec811\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #1a202c;color:#1a202c\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #1a202c;color:#1a202c\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6b0413afec811\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Why_your_favicon_disappears_in_dark_mode\" >Why your favicon disappears in dark mode<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Can_one_favicon_work_in_both_dark_and_light_mode\" >Can one favicon work in both dark and light mode?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Method_1_Make_an_adaptive_SVG_favicon\" >Method 1: Make an adaptive SVG favicon<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Option_A_Change_the_colours_inside_the_SVG\" >Option A: Change the colours inside the SVG<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Option_B_Put_your_light_and_dark_PNG_favicons_inside_one_SVG\" >Option B: Put your light and dark PNG favicons inside one SVG<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Add_the_SVG_favicon_to_your_page\" >Add the SVG favicon to your page<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Method_2_Two_favicon_files_with_a_media_attribute\" >Method 2: Two favicon files with a media attribute<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Which_browsers_support_dark_mode_favicons\" >Which browsers support dark mode favicons?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#How_to_add_a_dark_mode_favicon_in_WordPress\" >How to add a dark mode favicon in WordPress<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Bonus_a_readable_icon_in_the_black_admin_bar\" >Bonus: a readable icon in the black admin bar<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#How_to_test_your_favicon_in_dark_mode\" >How to test your favicon in dark mode<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Method_3_Design_one_favicon_that_works_on_both_backgrounds\" >Method 3: Design one favicon that works on both backgrounds<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Common_problems_and_fixes\" >Common problems and fixes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Frequently_asked_questions\" >Frequently asked questions<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Can_I_upload_two_favicons_for_dark_and_light_mode_in_WordPress\" >Can I upload two favicons for dark and light mode in WordPress?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Does_a_dark_mode_favicon_work_in_Safari\" >Does a dark mode favicon work in Safari?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#What_is_prefers-color-scheme\" >What is prefers-color-scheme?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Do_I_still_need_a_faviconico_or_PNG\" >Do I still need a favicon.ico or PNG?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-dark-light-mode\/#Will_a_dark_mode_favicon_slow_down_my_site\" >Will a dark mode favicon slow down my site?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Why_your_favicon_disappears_in_dark_mode\"><\/span>Why your favicon disappears in dark mode<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Most favicons are drawn for a white or light grey tab bar. When the browser or the operating system switches to dark mode, the tab bar turns dark grey or black, but the favicon file stays the same. A dark logo on a transparent background then has nothing to stand out against.<\/p>\n<p>You can see it in your own WordPress admin bar too: WordPress shows your Site Icon in the black bar at the top of every admin screen, so a dark icon is hard to spot there even in light mode.<\/p>\n<p>There are three ways out:<\/p>\n<ul>\n<li><strong>One adaptive SVG favicon<\/strong> that changes colour by itself. This is the best option for most sites.<\/li>\n<li><strong>Two separate favicon files<\/strong> chosen with a media query in the link tag. Simple, but only some browsers honour it.<\/li>\n<li><strong>One icon that works on both<\/strong>, with a white or coloured backing shape. No switching at all, and it works everywhere.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Can_one_favicon_work_in_both_dark_and_light_mode\"><\/span>Can one favicon work in both dark and light mode?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Yes. An SVG file is just text, and it can carry its own CSS. Inside that CSS you can use the same <code>prefers-color-scheme<\/code> media query that websites use for dark themes. When the browser draws the favicon, it checks whether it is in dark mode and applies the matching colours. You upload one file and never touch it again.<\/p>\n<p>The browser decides based on its own light or dark theme, which normally follows your computer or phone setting. That is also what you want: the icon matches the tab bar it sits on, not the colours of your web page.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Method_1_Make_an_adaptive_SVG_favicon\"><\/span>Method 1: Make an adaptive SVG favicon<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"Option_A_Change_the_colours_inside_the_SVG\"><\/span>Option A: Change the colours inside the SVG<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>If your icon is a simple shape or a letter that already exists as an SVG (most logo tools and favicon generators can export one), open it in a text editor and add a <code>&lt;style&gt;<\/code> block. This example draws a dark icon normally and a white one in dark mode:<\/p>\n<pre><code>&lt;svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 64 64\"&gt;\n  &lt;style&gt;\n    .mark { fill: #1b1e27; }\n    .accent { fill: #f47b20; }\n    @media (prefers-color-scheme: dark) {\n      .mark { fill: #ffffff; }\n    }\n  &lt;\/style&gt;\n  &lt;path class=\"mark\" d=\"M32 4 39.5 23.5 60 24.5 44 37.5 49.5 58 32 46.5 14.5 58 20 37.5 4 24.5 24.5 23.5Z\"\/&gt;\n  &lt;circle class=\"accent\" cx=\"32\" cy=\"32\" r=\"7\"\/&gt;\n&lt;\/svg&gt;<\/code><\/pre>\n<p>Give each part of your logo a class, set its normal colour, then set the dark-mode colour inside the media query. Brand colours that read on both backgrounds (like the orange dot above) can stay the same. Save the file as <code>favicon.svg<\/code>.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Option_B_Put_your_light_and_dark_PNG_favicons_inside_one_SVG\"><\/span>Option B: Put your light and dark PNG favicons inside one SVG<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Maybe you already have two finished favicons: a dark one for light mode and a light one for dark mode, made in Canva or another design app. You don&#8217;t need to redraw them as vectors. An SVG can hold two images and show only one at a time:<\/p>\n<pre><code>&lt;svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 96 96\"&gt;\n  &lt;style&gt;\n    .dark-icon { display: none; }\n    @media (prefers-color-scheme: dark) {\n      .light-icon { display: none; }\n      .dark-icon { display: inline; }\n    }\n  &lt;\/style&gt;\n  &lt;image class=\"light-icon\" width=\"96\" height=\"96\" href=\"data:image\/png;base64,PASTE-LIGHT-MODE-PNG-HERE\"\/&gt;\n  &lt;image class=\"dark-icon\" width=\"96\" height=\"96\" href=\"data:image\/png;base64,PASTE-DARK-MODE-PNG-HERE\"\/&gt;\n&lt;\/svg&gt;<\/code><\/pre>\n<p>The important detail: <strong>the two PNGs must be embedded as base64 data, not linked by URL.<\/strong> When a browser uses an SVG as an image (and a favicon is an image), it does not load other files from inside it, so <code>href=\"favicon-dark.png\"<\/code> would show nothing. Convert each PNG to base64 with any free &#8220;image to base64&#8221; converter and paste the long string after <code>base64,<\/code>. Use small, square PNGs (96\u00d796 is plenty for a tab) so the file stays light.<\/p>\n<p>This is exactly how we set up the favicon on QuickOnlineTips: our black &#8220;Q&#8221; with its orange tail shows on light tabs, and a white &#8220;Q&#8221; takes over on dark tabs.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Add_the_SVG_favicon_to_your_page\"><\/span>Add the SVG favicon to your page<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Upload <code>favicon.svg<\/code> to your site (the root folder is easiest) and add the link tag to the <code>&lt;head&gt;<\/code>, after your existing icons:<\/p>\n<pre><code>&lt;link rel=\"icon\" href=\"\/favicon.ico\" sizes=\"32x32\"&gt;\n&lt;link rel=\"icon\" href=\"\/favicon.svg\" type=\"image\/svg+xml\" sizes=\"any\"&gt;\n&lt;link rel=\"apple-touch-icon\" href=\"\/apple-touch-icon.png\"&gt;<\/code><\/pre>\n<p>Keep the ICO or PNG icons. Browsers that can&#8217;t use SVG favicons fall back to them, and Google Search doesn&#8217;t list SVG among its supported favicon formats, so it needs a PNG or ICO. Our <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2026\/11\/favicon-size-guide\/\">favicon size guide<\/a> covers every size and format you need alongside the SVG.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Method_2_Two_favicon_files_with_a_media_attribute\"><\/span>Method 2: Two favicon files with a media attribute<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>HTML also lets you point to two separate files and let a media query choose:<\/p>\n<pre><code>&lt;link rel=\"icon\" href=\"\/favicon-light-tab.png\" media=\"(prefers-color-scheme: light)\"&gt;\n&lt;link rel=\"icon\" href=\"\/favicon-dark-tab.png\" media=\"(prefers-color-scheme: dark)\"&gt;<\/code><\/pre>\n<p>It looks tidy, but browser support is patchy. Chrome and other Chromium-based browsers honour the <code>media<\/code> attribute on icon links. Firefox ignores it and simply uses the last icon tag on the page, so one group of your visitors would get the wrong icon. Unless you only care about Chrome-based browsers, use the adaptive SVG instead. It reaches more browsers and needs one file.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Which_browsers_support_dark_mode_favicons\"><\/span>Which browsers support dark mode favicons?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<table>\n<thead>\n<tr>\n<th>Browser<\/th>\n<th>SVG favicon<\/th>\n<th>Dark mode switch inside the SVG<\/th>\n<th>media attribute on two icon links<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Chrome, Edge and other Chromium browsers<\/td>\n<td>Yes (version 80 and later)<\/td>\n<td>Yes<\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td>Firefox<\/td>\n<td>Yes (version 41 and later)<\/td>\n<td>Yes<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>Safari (Mac, iPhone, iPad)<\/td>\n<td>Yes (version 26 and later)<\/td>\n<td>No: shows the light version<\/td>\n<td>Don&#8217;t rely on it<\/td>\n<\/tr>\n<tr>\n<td>Older Safari and old browsers<\/td>\n<td>No: uses your PNG or ICO<\/td>\n<td>No<\/td>\n<td>No<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<figure id=\"attachment_71566\" aria-describedby=\"caption-attachment-71566\" style=\"width: 1568px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-71566 screenshot\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-caniuse-svg-favicons.png\" alt=\"Can I use table showing SVG favicon support in Chrome, Edge, Firefox, Safari and mobile browsers\" width=\"1568\" height=\"625\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-caniuse-svg-favicons.png 1568w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-caniuse-svg-favicons-300x120.png 300w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-caniuse-svg-favicons-1024x408.png 1024w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-caniuse-svg-favicons-150x60.png 150w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-caniuse-svg-favicons-768x306.png 768w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/qot-caniuse-svg-favicons-1536x612.png 1536w\" sizes=\"(max-width: 1568px) 100vw, 1568px\" \/><figcaption id=\"caption-attachment-71566\" class=\"wp-caption-text\">SVG favicon support by browser, from the <a href=\"https:\/\/caniuse.com\/link-icon-svg\" target=\"_blank\" rel=\"noopener\">Can I use<\/a> tables.<\/figcaption><\/figure>\n<p><strong>The Safari catch:<\/strong> Safari now shows SVG favicons, but it ignores the dark-mode media query inside them, so Safari users in dark mode still see your light-mode drawing. Plan for it: make sure the default (light-mode) version still has enough contrast on a dark tab, for example a mid-tone colour, a coloured accent, or a thin light outline. Then the worst case is &#8220;a little less crisp&#8221;, not &#8220;invisible&#8221;.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_add_a_dark_mode_favicon_in_WordPress\"><\/span>How to add a dark mode favicon in WordPress<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>WordPress&#8217;s Site Icon setting (Settings \u2192 General) takes one square image and writes the icon tags for you. It has no dark-mode option, and WordPress blocks SVG uploads to the Media Library by default for security reasons. So keep the Site Icon as your PNG fallback and add the SVG yourself:<\/p>\n<ol>\n<li><strong>Keep your Site Icon.<\/strong> Leave a square PNG (512\u00d7512) in Settings \u2192 General. WordPress uses it for the Apple touch icon and older browsers, and Google reads it.<\/li>\n<li><strong>Upload <code>favicon.svg<\/code> by file manager or FTP.<\/strong> In your hosting control panel&#8217;s File Manager, put it in the folder where WordPress is installed, next to <code>wp-config.php<\/code>. Open <code>yoursite.com\/favicon.svg<\/code> in a browser to check that it loads.<\/li>\n<li><strong>Add the link tag with a snippet.<\/strong> Install the free <a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" target=\"_blank\" rel=\"noopener\">Code Snippets<\/a> plugin (or use your child theme&#8217;s functions.php), add a new PHP snippet with the code below, set it to run everywhere and activate it.<\/li>\n<\/ol>\n<pre><code>function myprefix_dark_mode_favicon() {\n    echo '&lt;link rel=\"icon\" href=\"' . esc_url( home_url( '\/favicon.svg' ) ) . '\" type=\"image\/svg+xml\" sizes=\"any\"&gt;' . \"\\n\";\n}\nadd_action( 'wp_head', 'myprefix_dark_mode_favicon', 100 );\nadd_action( 'admin_head', 'myprefix_dark_mode_favicon', 100 );\nadd_action( 'login_head', 'myprefix_dark_mode_favicon', 100 );<\/code><\/pre>\n<p>The priority of 100 prints the SVG tag after WordPress&#8217;s own Site Icon tags. The three hooks matter:<\/p>\n<ul>\n<li><strong>wp_head<\/strong> adds it to every page of your site.<\/li>\n<li><strong>admin_head<\/strong> adds it to the WordPress dashboard. Without it, the admin tabs keep showing the plain Site Icon, which is the classic &#8220;my favicon looks dark only in wp-admin&#8221; problem.<\/li>\n<li><strong>login_head<\/strong> covers the login page.<\/li>\n<\/ul>\n<p>If WordPress lives in a subfolder or you put the file elsewhere, replace <code>home_url( '\/favicon.svg' )<\/code> with the full address of your file.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Bonus_a_readable_icon_in_the_black_admin_bar\"><\/span>Bonus: a readable icon in the black admin bar<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The WordPress admin bar is always black, so a dark Site Icon is hard to see there whatever mode you use. A one-line CSS rule shows your light version in the bar instead. Upload a white or light PNG of your icon to the Media Library, copy its URL, and add this to the same snippet:<\/p>\n<pre><code>function myprefix_admin_bar_icon() {\n    if ( ! is_admin_bar_showing() ) { return; }\n    echo '&lt;style&gt;#wpadminbar #wp-admin-bar-site-name img.site-icon{content:url(\"https:\/\/yoursite.com\/wp-content\/uploads\/icon-white.png\");}&lt;\/style&gt;';\n}\nadd_action( 'wp_head', 'myprefix_admin_bar_icon', 100 );\nadd_action( 'admin_head', 'myprefix_admin_bar_icon', 100 );<\/code><\/pre>\n<p>Only logged-in users who see the admin bar get this style, so visitors are not affected.<\/p>\n<p>After any of these changes, clear your caching plugin and CDN so pages serve the new tags.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_test_your_favicon_in_dark_mode\"><\/span>How to test your favicon in dark mode<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ol>\n<li><strong>Switch your system theme.<\/strong> Change Windows, macOS, Android or iOS to dark mode, or change your browser&#8217;s own theme, and look at the tab. Most browsers update the icon within a few seconds or after a reload.<\/li>\n<li><strong>Use Chrome DevTools without changing your settings.<\/strong> Press F12, open the menu (three dots) \u2192 More tools \u2192 Rendering, and set &#8220;Emulate CSS media feature prefers-color-scheme&#8221; to dark. The favicon follows the emulated setting.<\/li>\n<li><strong>Open the SVG directly.<\/strong> Visit <code>yoursite.com\/favicon.svg<\/code> in light and dark mode to see both versions full size.<\/li>\n<li><strong>Beat the favicon cache.<\/strong> Browsers cache icons hard. If nothing changes, try a private window, or add <code>?v=2<\/code> to the SVG address in your link tag once.<\/li>\n<\/ol>\n<h2><span class=\"ez-toc-section\" id=\"Method_3_Design_one_favicon_that_works_on_both_backgrounds\"><\/span>Method 3: Design one favicon that works on both backgrounds<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If you&#8217;d rather not deal with any switching, design the icon so it never depends on the tab colour:<\/p>\n<ul>\n<li><strong>Add a backing shape.<\/strong> A white or coloured circle or rounded square behind your mark gives it its own background on every tab bar.<\/li>\n<li><strong>Use a mid-tone colour.<\/strong> Strong orange, blue, green or red reads on both white and near-black. Pure black and pure white are the colours that fail.<\/li>\n<li><strong>Add a thin outline<\/strong> in a contrasting colour around a dark mark.<\/li>\n<\/ul>\n<p>The trade-off is size: a backing shape makes the mark itself smaller inside the 16-pixel space. That&#8217;s why sites that want a big, bold icon in the tab, with no circle around it, use the adaptive SVG. For more ideas on making the icon itself, see our list of <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2012\/07\/create-favicon-online-free\/\">free favicon generators<\/a>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Common_problems_and_fixes\"><\/span>Common problems and fixes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>The dark version never shows:<\/strong> check that the SVG tag comes after your other icon tags, that the file is served as <code>image\/svg+xml<\/code>, and that you are not testing in Safari.<\/li>\n<li><strong>The SVG favicon is blank:<\/strong> the images inside it are probably linked by URL. Embed them as base64 data instead.<\/li>\n<li><strong>Dark only in the WordPress dashboard:<\/strong> your snippet only uses <code>wp_head<\/code>. Add <code>admin_head<\/code> and <code>login_head<\/code>.<\/li>\n<li><strong>Google still shows the old icon:<\/strong> Google uses the PNG or ICO, not the SVG, and only updates after it recrawls your homepage. The size guide linked above explains how to request that.<\/li>\n<li><strong>The icon changes with the website&#8217;s theme toggle, not the browser:<\/strong> favicons follow the browser&#8217;s light or dark setting. A dark-mode button on your own site does not change them.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Frequently_asked_questions\"><\/span>Frequently asked questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"Can_I_upload_two_favicons_for_dark_and_light_mode_in_WordPress\"><\/span>Can I upload two favicons for dark and light mode in WordPress?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Not through the Site Icon setting, which takes one image. Keep one PNG as the Site Icon and add an adaptive SVG (holding both versions) with a small code snippet, as shown above.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Does_a_dark_mode_favicon_work_in_Safari\"><\/span>Does a dark mode favicon work in Safari?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Safari shows SVG favicons but does not apply the dark-mode rule inside them, so it always shows the light-mode version. Choose light-mode colours that still read on a dark tab.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_is_prefers-color-scheme\"><\/span>What is prefers-color-scheme?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>It is a CSS media query that tells a page or an image whether the user has chosen a light or dark theme. Inside an SVG favicon, it lets the icon pick colours that suit the tab bar.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Do_I_still_need_a_faviconico_or_PNG\"><\/span>Do I still need a favicon.ico or PNG?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Yes. Older browsers, some apps and Google Search use bitmap icons, so keep a PNG or ICO alongside the SVG.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Will_a_dark_mode_favicon_slow_down_my_site\"><\/span>Will a dark mode favicon slow down my site?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>No. A favicon is one small file that browsers cache. Keep any embedded PNGs small (96\u00d796) and the SVG stays a few kilobytes.<\/p>\n<p>Want the background on why this works? The web.dev article on <a href=\"https:\/\/web.dev\/articles\/building\/an-adaptive-favicon\" target=\"_blank\" rel=\"noopener\">building an adaptive favicon<\/a> walks through the same technique with a hand-drawn SVG.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A favicon that looks great on a white browser tab can almost disappear on a dark one. A black logo&#8230;<\/p>\n","protected":false},"author":4,"featured_media":71565,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[41],"tags":[],"class_list":["post-71569","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-search-engine-optimization"],"_links":{"self":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/71569","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/comments?post=71569"}],"version-history":[{"count":1,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/71569\/revisions"}],"predecessor-version":[{"id":71570,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/71569\/revisions\/71570"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media\/71565"}],"wp:attachment":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media?parent=71569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/categories?post=71569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/tags?post=71569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}