Dark Mode HTML Email: How to Code, Design and Test
A dark mode HTML email guide: how Apple Mail, Gmail and Outlook recolour emails, the meta tags and CSS that work, and how to design and test for both modes.
7 min read

On this page
A dark mode HTML email has to survive three behaviours: some email clients leave your colours alone, some recolour only light backgrounds and dark text (partial inversion), and some recolour everything (full inversion). You can take control only in clients that support the color-scheme meta tag and @media (prefers-color-scheme: dark), mainly Apple Mail and Outlook.com. Everywhere else, including the Gmail apps, the fix is design: colours, images and contrast that still work after the client changes them.
How do email clients handle dark mode?
Each client decides for itself, and the behaviour changes with app updates. Based on Google's documentation and Litmus's testing (February 2025):
No change
- Gmail on the web. Dark theme darkens the Gmail interface, but Google says email bodies are rendered on a light background by default.
- Apple Mail on iPhone, iPad and Mac. A normal HTML email stays as designed unless you add the dark mode meta tags. Once you declare dark mode support, Apple Mail applies your dark styles, and if you declare it without writing any, it darkens the email itself.
- Yahoo Mail and AOL.
Partial inversion
The client darkens light backgrounds and lightens dark text but leaves dark areas, such as a dark button, mostly alone. Litmus puts Outlook.com, the Outlook apps for iOS and Android, Outlook for Mac and the Gmail app for Android here. The new Outlook for Windows renders much like Outlook.com.
Full inversion
The client recolours light and dark areas alike. Litmus lists the Gmail app for iOS and classic Outlook for Windows (Microsoft 365 and Outlook 2021) here.
Microsoft also lets readers switch back: a sun button in classic Outlook turns the message background white, and a "Turn on the lights" button in Outlook.com and the new Outlook shows the original formatting.
Dark mode meta tags and prefers-color-scheme
To opt in to dark mode where clients allow it, declare support in the <head> and write dark styles inside a media query:
<head>
<meta name="color-scheme" content="light dark">
<meta name="supported-color-schemes" content="light dark">
<style>
:root { color-scheme: light dark; supported-color-schemes: light dark; }
@media (prefers-color-scheme: dark) {
.email-bg { background-color: #121212 !important; }
.email-card { background-color: #1e1e1e !important; }
.email-text { color: #e6e6e6 !important; }
.email-link { color: #8ab4f8 !important; }
}
</style>
</head>Put the classes on cells and links that also carry inline light-mode styles; !important lets the dark styles override them.
Where it works, according to caniemail:
- prefers-color-scheme: Apple Mail on Mac, iPhone and iPad, Outlook.com, Outlook for Mac, iOS and Android, and Samsung Email. Results in the Outlook apps have varied between tests, so check them. Gmail removes the query, and classic Outlook for Windows and Yahoo Mail ignore it.
- The meta tag and CSS property: Apple Mail on Mac honours the meta tag, and caniemail confirms the CSS
color-schemeproperty on the root element in Apple Mail on Mac and iPhone. That's why the sample sets both.
Gmail is the exception worth knowing. Google's Gmail CSS documentation says the Gmail apps ignore dark mode CSS, but for Google accounts they respect <meta name="color-scheme" content="light only">, which stops the apps recolouring your email. It's an either/or choice: the tag can't say "light dark" and "light only" at once, and "light only" means readers who chose dark mode get a bright email in Gmail.
Outlook.com's data-ogsc and data-ogsb selectors
When Outlook.com recolours an element in dark mode, it stores the original value in an attribute: data-ogsc for a changed CSS text colour and data-ogsb for a changed CSS background (plus data-ogac and data-ogab for HTML colour attributes). caniemail notes the same attributes in the Outlook apps. Because they only appear in dark mode, email developers use them as selectors:
[data-ogsc] .email-text { color: #e6e6e6 !important; }
[data-ogsb] .email-card { background-color: #1e1e1e !important; }
These rules only match inside a parent Outlook has already recoloured, so they rely on an outer wrapper with a light background and dark text. Treat this as a hack: Microsoft doesn't document it, caniemail last recorded it in 2023 and Litmus rates support as partial. Use it only to fine-tune Outlook, never for anything the email depends on.
How to design colours and images that survive inversion
In the Gmail apps and classic Outlook you can't send dark styles, so the design itself has to cope:
- Keep text as live HTML text. Clients recolour HTML text and backgrounds, but the pixels inside an image stay the same. A headline baked into a white image becomes a bright rectangle on a dark screen.
- Watch transparent PNGs. Dark artwork on a transparent background can vanish once the background turns dark. Give it a subtle light outline or glow, or place it on a solid shape inside the image. Logos are the usual casualty, and I've covered the Gmail logo fixes in a separate article.
- Choose mid-tone brand colours. Very light tints often get darkened, and very dark ones may be lightened. A colour that reads well on both white and black survives best.
- Use strong button colours. Partial inversion tends to keep dark button backgrounds. A strong button colour with white text usually comes through intact.
- Check thin lines and borders. Light grey dividers can disappear or turn harsh after inversion.
When I write dark styles, I use a dark grey such as #121212 instead of pure black and an off-white for text, which is easier on the eyes. I make these decisions while coding every HTML email template, because dark mode is far easier to plan into a design than to patch after launch.
Dark mode email accessibility: contrast in both modes
Accessibility in dark mode means checking contrast twice. WCAG asks for a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text (18pt, or 14pt bold). Check your light palette and your dark palette separately.
Good contrast also means fewer surprises: Outlook.com has been documented recolouring text whose contrast against its dark background falls below 4.5:1.
Links need attention too. A standard blue link that passes on white can fail on a dark background, so give links a lighter colour in your dark styles and underline them so they never rely on colour alone. Finally, think before you force light mode: people often choose dark mode for comfort or light sensitivity.
How to preview and test dark mode emails
- Check the code first. The HTML email checker flags code-level basics before any send, such as dark styles without the
color-schememeta tag, images without alt text and layout tables missingrole="presentation". It checks the code only, not how inboxes render it. - Test on real devices. Switch an iPhone or Mac to dark appearance and open the email in Apple Mail. Set the Gmail app's theme to dark on iOS and Android, since the two invert differently.
- Test Outlook. Turn on dark mode in Outlook.com and switch classic Outlook to the Black Office theme.
- Use a testing platform such as Litmus or Email on Acid for dark mode previews across clients you don't own.
Skip Gmail's web theme for this: it keeps email bodies light. In each client, check the logo, buttons, dividers, text over images and footer links.
FAQ
Can I stop Gmail from changing my email colours in dark mode?
In the Gmail apps, Google documents <meta name="color-scheme" content="light only"> for Google accounts, which keeps your email in light colours. Gmail on the web already shows email bodies on a light background. You can't send custom dark styles to Gmail at all.
Does Outlook support dark mode in HTML email?
Partly. Outlook.com and the Outlook apps for Mac, iOS and Android support prefers-color-scheme according to caniemail, though results vary. Classic Outlook for Windows ignores it and inverts colours itself, so the design has to survive that.
How do I make an email signature work in dark mode?
You can't add dark mode CSS to a signature: Gmail, for example, removes <style> blocks from HTML pasted into it, so signatures rely on inline styles. Use live text instead of images of text and a logo that works on dark backgrounds, such as a transparent PNG with a light outline.
Do I need a separate dark version of my email?
No. You send one email with light styles inline and optional dark styles in a media query. Clients that support dark mode CSS use your dark styles, and the rest apply their own inversion.
Key takeaways
- Email clients either leave colours alone, invert them partly or invert them fully.
- Dark mode CSS works mainly in Apple Mail and Outlook.com; Gmail ignores it.
- Design so the email survives inversion: live text, mid-tone colours, logos with outlines.
- Check contrast in both modes and test on real devices, not Gmail's web theme.
Tags
- HTML Email
- Dark Mode
- Email Development
- Best Practices

About Keshur Gojiya
Web developer and HTML email specialist with 6+ years of experience, building websites and emails for businesses, startups and agencies.
Get to know me

