26
loading...
This website collects cookies to deliver better user experience
favicon.ico
using the setting: 32 bpp, 8-bit alpha, no palette.manifest.json
or manifest.webmanifest
, and is typically placed in the root directory of your website.<link rel='mask-icon'>
. Safari 12+ use a regular favicon for pinned tabs now.browserconfig.xml
file.width
and height
attributes on the SVG, you can use viewBox
to define the dimensions.<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500">
<!-- stuff -->
</svg>
prefers-color-scheme
CSS media feature can be used to detect if the user has requested a light or dark color theme in the browser and will cover most scenarios. Scenarios that I found that this does not cover are:In the history dropdown in browsers, the favicons used are probably cached and are not affected by the user’s theme. You can see in the screenshot below that the BBC and GitHub favicons are hard to identify.
On the traffic page on Github, favicons for referring sites are displayed inline alongside the web address. Even GitHub's favicon falls foul here if you have dark mode set in the GitHub settings, you can see this below! Or can you? 😑
prefers-color-scheme
media query. This will adapt the favicon to the user's chosen theme. Depending on the style of your favicon, you may want to change the colours used, or you could use a filter to adjust the existing colours.<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500">
<style>
@media (prefers-color-scheme: dark) {
path {
fill: white;
}
}
</style>
<!-- stuff -->
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500">
<style>
@media (prefers-color-scheme: dark) {
:root {
filter: brightness(2);
}
}
</style>
<!-- stuff -->
</svg>
/img/favicon/
, just to make things cleaner. I would still put favicon.ico
in the root directory, because some web services and older browsers still look here for this file. The rest is covered by what you specify in your meta-data..
├── favicon.ico // must be named this way and located at root
├── manifest.json // the convention is to have this in the root dir
├── img/ // you can choose where to put the rest of the images
│ └── favicon/
│ └── favicon.svg
│ └── favicon-180.png
│ └── favicon-192.png
│ └── favicon-512.png
head
of your website:<head>
<link rel="icon" href="/favicon.ico">
<link rel="icon" href="/img/favicon/favicon.svg" type="image/svg+xml" sizes="any">
<link rel="apple-touch-icon" href="/img/favicon/favicon-180.png">
<link rel="manifest" href="/manifest.json">
</head>
<meta name="theme-color" content="<color>"
for consistency. This suggests the color to be used by browsers and apps to style elements of the UI background. For example, browsers might use the color for the page’s title bar. You can specify a media query for the themes also.<meta name="theme-color" media="(prefers-color-scheme: light)"
content="antiquewhite">
<meta name="theme-color" media="(prefers-color-scheme: dark)"
content="silver">
{
"name": "My blog",
"icons": [
{ "src": "/img/favicon/favicon-192.png", "type": "image/png", "sizes": "192x192" },
{ "src": "/img/favicon/favicon-512.png", "type": "image/png", "sizes": "512x512" }
]
}