PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label darkmode. Show all posts
Showing posts with label darkmode. Show all posts

Sunday, October 23, 2022

[FIXED] How do I match the background color of my HTML email to the background color of the email client?

 October 23, 2022     apple-mail, css, darkmode, email, html-email     No comments   

Issue

I'm working on creating an html email template. I'm new to developing HTML specifically for email, and I know it can be quite finicky.

I want the background of the email to match the background of the email client(Apple Mail, Gmail, Outlook, etc.) This seems to be the default for plain-text emails. But when creating an HTML email, I find that as soon as I add anything besides text within the <body> tag, the default background color for the email becomes white. The main reason for why I want to achieve this is so that my emails will match light mode and dark mode settings.

How do I make it so the email background will match that of the email client? Is there a way to make the HTML content have no background, or perhaps a transparent background? Or inherit the background color from the email renderer? Or do I need to detect the email client(or dark mode settings?), and change the background-color manually? Any weird work-arounds? And if any of these answers are possible, how is it done?

I know it is at least possible to achieve this within Apple Mail, as I found this example of an email that changes background color to match dark mode vs. light mode:

Example of email matching background color between light and dark mode


Solution

You can use the following, it currently works in 33% of email clients.

@media (prefers-color-scheme: dark) {
  /* Dark theme styles go here */
}


@media (prefers-color-scheme: light) {
  /* Light theme styles go here */
}

Checkout the following article that goes into more detail.

https://medium.com/swlh/dark-mode-in-html-email-everything-you-need-to-know-57b2647bf304



Answered By - cam
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Saturday, May 14, 2022

[FIXED] Why `window.matchMedia('(prefers-color-scheme: dark)').matches` returns `false` in Ubuntu Dark Mode

 May 14, 2022     darkmode, javascript, ubuntu     No comments   

Issue

I'm using Ubuntu and trying to get the preferred theme of the user, by using matchMedia but it always returns false for this query.

window.matchMedia('(prefers-color-scheme: dark)').matches // false

Solution

This is an open issue in Chrome.



Answered By - Qwerasd
Answer Checked By - Terry (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing