Emails in Dark Mode: Enhancing the User Experience

I am currently working on a project involving emails and I need to implement a dark mode for the email body. The email body is comprised of HTML with specific color styles defined. My objective is to change the text and background colors to create a dark mode display. To achieve this, I will define a dark scheme style as follows:

@media (prefers-color-scheme: dark) {
    html {
        filter: invert(1) hue-rotate(180deg);
    }

    img, video {
        filter: invert(1) hue-rotate(180deg);
    }
}

While flipping the overall colors, the pictures and videos appear satisfactory after being flipped back. However, one issue arises - emojis also undergo color inversion, resulting in an unsightly appearance.

https://i.sstatic.net/UtfDW.jpg

I attempted a solution involving color blending:

   color: white;
   mix-blend-mode: screen;

This method brightens emoji colors but fails to turn black texts into white.

The main question remains: How can I make the following text display in white while keeping emojis unaffected?

<div style="color: black;">
      Hello world!  😊 😄 😭
</div>

Desired outcome:

https://i.sstatic.net/cahdv.jpg

--- Edited ---

An excellent example is the Apple Mail app:

https://i.sstatic.net/X816f.jpg

When sending an email with HTML content:

<div>Test colors: </div>
<div style="color: black;">Black</div>
<div style="color: green;">Green</div>
<div style="color: red;">Red</div>
<div style="color: pink;">Pink</div>
<div style="color: blue;">Blue</div>
<div style="color: yellow;">Yellow</div>
<div style="color: gray;">Grey</div>
<div style="color: white;">White</div>
<div style="color: #8300bb;">Purple</div>

Answer â„–1

To properly display emojis on your website, it's recommended to place them within a span element with a class of emoji. Additionally, in your CSS code, make sure to implement an inversion effect.

Interestingly, by applying the invert effect twice, you can revert something back to its original appearance! :)

Consider using the following CSS snippet:

html {
     background: white;
     color: black;
}

@media (prefers-color-scheme: dark) {
    html {
        filter: invert(1);
    }
    .emoji { 
        filter: invert(1); 
    }
}
<div> Hello world! 
    <span class="emoji">😊 😄 😭</span> 
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is a simple way to export an HTML table to an Excel file in ASP.NET?

We need to create a report from the database and include an export button so users can download the report in an Excel-readable format. The priority is on simplicity of implementation, so using CSV is preferred over XLS if it's more straightforward. ...

Tips for adjusting the size of iframe content to fit its div area in Bootstrap 4 when the window is minimized

I recently started building a website and encountered an issue with resizing the window to fit an iframe containing a video within a div. I'm unsure where exactly in the CSS code I need to make adjustments for this. Can someone help me out? The websi ...

What causes certain CSS properties to scroll while others remain fixed?

I am experiencing a strange issue with my table. I am utilizing the tableHeadFixer jQuery plugin to create a fixed header with a scrollable table body. In my CSS, I have a class called table which is defined as follows: .table thead { color: blue; ...

What is the best way to incorporate a unique font into text using CSS?

Similar Question: How do I implement custom fonts in CSS? Is there a way to use CSS to define a custom font for elements like a <div>? I've heard about using @font-face ... but it doesn't seem to be effective in IE or Chrome. ...

What is the best way to save CSS within a Django class?

Currently, I am in the initial stages of planning a Django application that will generate html5 slideshow presentations. My goal is to have the ability to customize the style of each slide object by defining CSS attributes such as colors and sizes. Additio ...

How can I make the navbar in Angular stay fixed in place?

After using the ng generate @angular/material:material-nav --name=home command to create a navbar, I am trying to make it fixed at the top while scrolling. I attempted using position: fixed; on my mat-sidenav-content but it didn't work. Does anyone ha ...

Storing an HTML page in a PHP variable, parsing it, and displaying it correctly

I am currently using the simple_html_dom parser to extract information from an HTML page. After making some modifications, I would like to display this content on my own page. $page = file_get_html($url); foreach($page->find('div#someDIv') as ...

Update the bootstrap navigation bar

I'm currently using bootstrap to construct my website. The navbar I have is quite typical with menu options, but I am aiming to modify the CSS in order to achieve a design similar to the image provided below (this design should be responsive and funct ...

Footer that sticks to the bottom of the page across various pages

Having trouble printing a 2-page document on Chrome. The first page has fixed content while the second page has dynamic content in an extended table. The problem I'm facing is keeping the footer at the bottom of the second page. The CSS code below wo ...

Issue with table cell resizing improperly with scrollable pre content

I'm facing a challenge with resizing my table cell correctly within a variation of the "holy grail" layout. The behavior differs when displaying my main content as a block versus a table-cell. The issue seems to stem from having a scrollable pre bloc ...

Ways to extract transparency data of each pixel from a PNG uploaded by the user via the front-end

Currently, I am in need of extracting the transparency value for each individual pixel from a PNG image that is submitted by the user, directly within the front-end environment. At the moment, I have implemented a method where I prevent the form from bein ...

The behavior of Elementor lightbox buttons upon being clicked

When using Android, I've noticed that the lightbox briefly displays a semitransparent cyan bar on the left and right buttons when they are pressed. Is there a way to control or prevent this behavior? Any suggestions would be appreciated! Thanks in adv ...

"Why is it that only one of the two similar spans with onclick event is not functioning properly

Encountering a perplexing issue that has me stumped. Here's the code in question: js: function Test() { alert("test"); } html: <span id='bla' onclick='Test()'> Click me </span> <hr> <span id='bla2& ...

Menu with a slider featuring three different choices

I am currently working on creating a box with a title and two arrows positioned to the left and right of the title. The goal is for the box to fade out when either arrow is clicked, and then fade in with the next option. I have a similar setup already impl ...

What methods can we use to transform Bootstrap rows and columns to resemble a table design?

Attempt number one did not work due to padding issues in the columns. Attempt number two also failed, leading me to believe I may be making a mistake somewhere. This is what I am aiming for: https://i.sstatic.net/yTz6o.png Can anyone provide some assis ...

How to apply CSS styling to a specific element using jQuery

When using $(".className"), all elements with the class .className are returned. How can I target a specific element by its index number to apply styling only to that element? <html> <head> <script src="https://ajax.googleapis.com/ajax ...

Enhance your user experience by implementing a jQuery solution that makes a div

Looking to add a small div on the right side of your screen that moves along with your vertical window slider? Wondering if jQuery has a function to get the current vertical slider position? I thought scrollTop() might work, but it only returns from a spe ...

Navigate to the first item on the menu in the Chrome browser

Why does the First Menu Item (.chosen) jump in Chrome Browser when refreshed? It seems like it's changing the Padding-Right and Padding-Bottom. Please review the code and help me solve this irritating issue. It works fine in Firefox. <body> ...

What is the best way to toggle the visibility of a dynamically created HTML element in ASP.NET?

I'm working on a program that displays two different prices depending on whether the user is registered or not. Registered users will see both the normal price and the discounted price, while unregistered users will only see the normal price. I need t ...

Error alert: The function is declared but appears as undefined

Below is the javascript function I created: <script type="text/javascript"> function rate_prof(opcode, prof_id) { $.ajax({ alert('Got an error dude'); type: "POST", url: "/caller/", data: { ...