Can Gmail emails adapt to dark mode using CSS media queries?

I’m trying to make my HTML emails change colors when the user’s device is in dark mode. I’ve put this CSS in the head of my email:

@media (prefers-color-scheme: dark) {
  .night-bg {
    background: navy !important;
  }
}

It works fine in the Apple Mail app. The email body changes color as expected. But in the Gmail app, it doesn’t do anything. Gmail just turns everything dark on its own, and it doesn’t look great.

Does anyone know why this media query doesn’t work in Gmail? Is there a way to make Gmail emails respond to dark mode settings? I’d really like to control how my emails look in both light and dark modes. Any tips or workarounds would be super helpful!

I’ve been grappling with this issue too. Gmail’s lack of support for dark mode media queries is indeed a pain. What I’ve found to work reasonably well is using a color palette that’s neutral enough to look decent in both light and dark modes. Think muted tones and avoiding stark contrasts.

Another trick I’ve had some success with is using background images instead of solid colors for key elements. These tend to render better across different email clients and modes. It’s not perfect, but it helps maintain a more consistent look.

Ultimately, thorough testing across various devices and email clients is crucial. It’s time-consuming, but it’s the only way to ensure your emails look good for most recipients, regardless of their viewing preferences or email client quirks.

I’ve encountered this issue in my email marketing campaigns. Gmail’s handling of dark mode is indeed problematic for designers. One approach I’ve found effective is using color-scheme: light dark; in the CSS. This tells email clients to use their native dark mode colors, which often yields better results than trying to force custom styles.

Another strategy is to use rgba() colors with transparency. This allows the background to show through, adapting to both light and dark modes more gracefully. For example, rgba(255,255,255,0.8) for light text on dark backgrounds.

Remember, email design often requires compromise. Aim for a design that degrades gracefully across different clients and modes, rather than striving for pixel-perfect consistency everywhere.

unfortunately gmail doesn’t support media queries for dark mode :frowning: its a known limitation. youll have to use a different approach, like detecting dark mode with javascript or using specific color schemes that look ok in both modes. its frustrating but thats how it is with gmail right now