As I embark on creating an HTML email template, I am venturing into the realm of developing for emails, which I know can be quite temperamental. The challenge I'm facing is in making sure that the background of my HTML email matches that of the email client (Apple Mail, Gmail, Outlook, etc.). In plain-text emails, this seems to happen automatically, but once I introduce any elements beyond text within the <body>
tag, the default background color changes to white.
The reason behind my quest for a matching background is to align with both light and dark mode settings across different email clients. How can I achieve this seamless transition between email backgrounds? Is it possible to have transparent or inheritance-based backgrounds for the HTML content, or do I need to manually detect the client or dark mode settings and adjust the background color accordingly? Are there any unconventional solutions to this dilemma, and if so, how can they be implemented?
I've come across an example of an email that successfully adjusts its background color to match dark and light modes in Apple Mail, proving that it is indeed achievable: