When viewing HTML emails in dark mode on iOS Gmail, the CSS appears to be inverted

While sending an HTML email from a nodejs app, I encountered an issue with Gmail on iOS where elements with background-color or color properties were getting reversed. This was most noticeable on black and white elements. Despite consulting various guides and articles on the matter, none of the suggested solutions proved effective.

I attempted to resolve the issue by adding the following meta tags:

<meta name="color-scheme" content="light">
<meta name="supported-color-schemes" content="light">

While Outlook on iOS responded correctly to these tags, Gmail on iOS did not.

Further efforts to address the problem included trying to override the display using the following media tag:

@media (prefers-color-scheme: dark ) {
#header {
background-color: black!important;
height: 60px;
padding-left: 15px;
padding-right: 15px;
/* padding: 17px; */
 }
 #headerLink{
  color: white!important;
}
}

Answer №1

Regrettably, Gmail does not currently support the media query that you were trying to implement. Take a look at this informative tablehttps://i.stack.imgur.com/2QVt7.png

Nevertheless, CSS blend modes are now compatible with Gmail, offering a solution for your needs. I stumbled upon this insightful article online.

The article suggests using `screen` and `difference` blend modes in order to counteract color inversion by Gmail, effectively maintaining the original colors. It also includes a method to specifically target Gmail without affecting other email platforms:

"Gmail replaces the doctype of an email with a <u> element." By utilizing the adjacent sibling combinator +, you can pinpoint the desired element (remember to assign a class to your <body>).

u + .body .yourElement{ mix-blend-mode: difference; }

As long as you avoid using a <u> element elsewhere (which is uncommon in modern practices), this method should work smoothly. Additionally, blend modes enjoy widespread browser support (96%+) these days.

Trust this information proves helpful to you!

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

tap into adhesive, translucent screen

I designed a webpage with an iframe at the bottom that I set to be transparent so that overlapped elements are visible. However, I encountered an issue where the links beneath the iframe were not clickable unless I disabled pointer-events for the iframe. ...

Display 3 images with the carousel feature on the middle image

Currently, I am utilizing the jquery.jcarousellite plugin and attempting to make the second image active. Below is the code snippet I have tried: <div id="jcl-demo"> <div class="custom-container auto moreItems "> <a href="#" c ...

Is there a possible workaround for the restriction on temporary downloads by Heroku?

When my app starts, I aim to download images from MongoDB for faster performance and local access within the application. However, I encounter crashes on Heroku. How can I address this issue? Here is the code snippet I am attempting to implement: dir = " ...

Adjusting the amount of rows and columns in a fluid manner with CSS grid (updated)

After conducting my research, it seems that the most effective way to set the final value of a CSS grid is either by directly specifying it or by creating/manipulating the css :root value. A similar query was previously raised here, although the answers p ...

Tips on adjusting the size of a Materialize CSS datepicker to perfectly fit within a card

Currently, I am developing a login page in html utilizing the materialize css framework. In my design, I created a card where Login and Register are displayed as tabs within the card. However, one of the forms includes a datepicker from materialize which ...

What are the steps for launching a NodeJS application that operates under HTTPS?

I am facing an issue while trying to deploy my app using HTTPS on the same server with Direct Admin. Initially, I set the port to 8443 and started the server using node index.js. The server indicated that it is running on port 8443. However, upon attempti ...

Using Cordova to create an accordion list on an HTML webpage

I am in need of an accordion list implementation for the given HTML code. I specifically want it to expand when 'Technical' is clicked, and collapse upon clicking again. Here is the HTML code: <!-- Techincal --> <div class= ...

Enhance the <div> with interactive content through dynamic updates on click within the same element

I am currently developing an Editor-Menu for a website administration. When I open admin.php, the Editor-Menu should be loaded into the #ausgabe div using the code $('#ausgabe').load('./admin-ajax/ajax2.php'). This functionality is work ...

Animating the background of a div element using jQuery

I am facing an issue with the code snippet below that I have written. It doesn't seem to be working as expected and I'm curious if anyone knows why. The problem is that I have set a background color on the DIV, but when hovering over it, I want ...

Bug on a Safari browser when using a dotted border on a table

Issue in Safari and Chrome browsers: CSS: TABLE { width: 100%; clear: both; border: 0px; border-collapse: collapse; } TABLE TH, TABLE TD { padding: 10px; text-align: center; border: 1px dotted #898989; } ...

The POST request from the form is returning a null value

I am currently facing an issue with using post in Express and BodyParser to insert data from a form in an EJS file into MySQL. The data keeps returning null, indicating that it is not being parsed correctly from the form to the backend. Can anyone offer as ...

What is the best way to access the tooltip text in Reddit?

Currently, I am in the process of developing a Selenium web scraping tool specifically for Reddit. However, I am encountering some challenges in extracting the timestamp displayed in the image. from selenium import webdriver from webdriver_manager.chrome i ...

Ways to create a responsive Instagram iframe without using JavaScript

Currently, I am attempting to create a responsive grid featuring Instagram posts. Unfortunately, the padding-bottom hack isn't effective for my particular situation. After some experimentation, I discovered that the height could be calculated by addin ...

What is the most effective approach to building this function in React JS rather than the existing .map method?

Hello, I'm fairly new to all of this so please bear with me. I've been working on developing a search function for my app, but I've encountered a problem. The search function in my header component is being rendered like this in my index: &l ...

Clicking elements reveal but page height remains unchanged?

Clicking on a label within #row-product_id_page-0-0 triggers the display of #row- elements as shown in the code snippet below: $('#row-product_id_page-0-0 label').click(function() { var str = $(this).find('.am-product-title').text ...

Discover the method to extract next/image from next.js

Is it possible to install only the next/image module from Next.js without installing the entire Next.js module? I attempted the following - "next/image": "^10.0.5", "next/link": "^10.0.5", However, after running npm ...

Guidelines for implementing an onSubmit function using Material-UI

Hey there, I'm relatively new to node.js / react / material-ui. Following a tutorial to build a website has been going smoothly so far. I decided to spice things up by adding material-ui for some sleek components (which weren't covered in the tut ...

The API response was blocked due to the CORS header "Access-control-allow-origin."

I have an index.html file that is used for making HTML and Ajax calls. When I run the file through localhost, the API works perfectly. However, if I directly open the index.html file in Google Chrome or Mozilla Firefox, I encounter a CORS (Cross-Origin Re ...

What are some effective ways to analyze jQuery and JavaScript using web development tools?

I'm struggling to use web development tools to inspect the JavaScript on websites. It's challenging to identify which parts of a site are utilizing JS, unlike CSS or HTML where it's more visibly defined. Even when I attempt to delete some J ...

Utilizing ExpressJS: A guide on rendering all existing njk template files

Is it possible to render any njk file using express and nunjucks? The examples I've seen online only show: app.get('/', function (req, res) { res.render('index.njk'); }); But how can this be implemented in a more dynamic way? ...