How to use different favicon assets for Light and Dark Modes - A Quick Dev Guide.
Tobi Emmanuel
Building Exciting Web Experiences | Frontend Technical Manager @ Eastside Co | Web Accessibility Advocate | MDes. | Beta Gamma Sigma
Still using dark coloured favicon images in 2025? ?? (Yes I'm judging you)
Let's start with definitions.
Favicon: an icon associated with a particular website, typically displayed in the address bar of a browser accessing the site or next to the site name in a user's list of bookmarks. (Oxford dictionary)
Light mode: Light mode, also known as "Light Theme" or "Day Mode," refers to a user interface design scheme characterised by bright backgrounds and dark text. (Solute Labs)
Dark mode: Dark mode is a feature that changes the colour scheme of an application or website from light to dark. It's a popular option for those who prefer a less bright and more subdued interface. (Interaction Design Foundation)
Why is this guide important?
Since the introduction of mode switch on user devices, The use of dark mode has increasingly become popular, and so has the need to ensure your websites and apps work for users based on their colour mode preference to enhance user experience.
The guide (Purely HTML)
<head>
<!-- Default favicon (for browsers that don't support media queries in link tags) -->
<link
rel="icon"
href="[DEFAULT-FAVICON-URL]"
type="image/x-icon"
>
<!-- Light mode favicon -->
<link
rel="icon"
href="[DARK-MODE-FAVICON-URL]"
type="image/x-icon"
media="(prefers-color-scheme: light)"
>
<!-- Dark mode favicon -->
<link
rel="icon"
href="[LIGHT-MODE-FAVICON-URL]"
type="image/x-icon"
media="(prefers-color-scheme: dark)"
>
</head>
NOTE: I put each LINK attribute on its own line for readability. You don't have to do it this way.
So lets break it down
Limitations to consider
In the past dark/light mode favicon changes were usually done via Javascript so as to programmatically control the switch by a toggle or button. With many devices now having inbuilt dark/light mode global settings, I find the need for this toggle is not as popular as it used to be, and most applications can now rely on pure HTML to resolve this UX issue.
If however your build requires a toggle switch, this solution might not be for you.
Another limitation would be poor support on older devices/browsers.
Conclusion
I hope this guide is quick and easy enough to implement in your projects. Happy building! and please drop a comment if you found this useful in any way. x