Reputation: 55
am designing a html email template that supports dark mode for all email clients but am facing a problem with the logo.
The logo is a black .png image and the default/light background is white, so in dark mode it becomes black over black. Adding an outline to the logo is not an option, using 2 images with classes and controlling which one to display using media queries won't work for Gmail ios and some outlook versions, so am left with three choices but am not sure wither they are applicable and supported by all famous clients:
<picture>
<source srcset="dark-mode.png" media="(prefers-color-scheme: dark)">
<img src="light-image.png">
</picture>
So, are any of them is applicable and supported? Also, more suggestions/ideas/options are appreciated.
Upvotes: 1
Views: 4912
Reputation: 5204
Support for SVG is quite limited so unfortunately that's not an option: https://www.caniemail.com/features/image-svg/
@media prefers-color-scheme: dark is not supported on Gmail/some Outlooks, so that's not going to work. https://www.caniemail.com/features/css-at-media-prefers-color-scheme/
Using a gradient to force unchanging background is not ideal (we should be supporting customer's preferences), and also not 100% cross-compatible. (background-image: linear-gradient(#ffffff,#ffffff);
)
If a 1px white stroke is no good for you, you could try a soft glow like Litmus do.
Alternatively, sometimes we just end up putting a single-colour background in the image itself (i.e. getting rid of the transparency), perhaps with rounded corners (a tiny bit of transparency on the corners). Works best for icons, but might be your only option.
Upvotes: 2