CSS: Dark Theme
here's how to make your website support dark theme.
Essentially, use
CSS: Media Query
on
prefers-color-scheme:dark
.
Then, set text color to white, and background color to black. Also, you might to add black background color to image tag, figure tag, or SVG files.
@media (prefers-color-scheme:dark) { body { color:white; background-color:black; } mark.unicodeXL, mark.emojiXL { color:white; background-color:transparent; } a:visited,a:link { color:dodgerblue; } }
No Major Journalism Site Use Dark Theme
One of the issue is to decide if you really want your site to support dark theme.
Dark theme appears to be a fad. Scientific studies seem to suggest, black text on white is actually better for your eyes, and lets you read faster.
Note, none of the major text-heavy sites support dark theme.
the following sites do not support dark theme:
- Wikipedia
- Wall Street Journal
- Fox News
- USA Today
- New York Times
- LA Times
- Time Mag
- Scientific American
- msn
- yahoo!
Shade of Dark for Dark Theme Background Color

Discord is the worst.
Black Border Problem
you need to change black border to grey or so

Add White Background to Img Tag
Another major problem is png files with transparent background. It's hell. This means, you need to write a script to find all png images on your site that has transparent background. You also need to check gif files and other image formats.
you want them to have white background. One easy fix is to use CSS to make all images white background.
@media (prefers-color-scheme: dark) { img { background-color:white; } }
in the following, the right image is desired. The left got screwed. Even if you remove alpha channel. Meaning, when removing alpha channel of png, you have to make sure, it uses a white background .

Check Pages with Image Background
If you are using a image for background, and if the image has background color white, then white text disappears.

Text is white, on a white image background. And there are 93 such img background CSS i have to look at case by case.

Problem. Embedded SVG
Embedded SVG that has transparent background needs to have a solid color. [see Practical SVG Tutorial]

programing code syntax coloring problem
Also, programing code syntax coloring is also a problem. Simply invert color or switch black/white create ugly coloring, e.g.

other problems
the following is the thought flow while i was making my website to support dark theme .
My site is pretty simple. Bascially just 5 lines of CSS will turn it to support dark theme. But there are about 200 SVG files and lots more PNG i need to manual change. In theory, they can be fixed with backdrop-filter CSS, probably. But the problem is, it's really a case by case nasty problem. Because depending on how the image is used.
The heart of the issue is, with images, sometimes u wan white background , sometimes transparent. Making them all explicit white doesn't work 100%. And they are not just all img tags. For example, img files are used as background CSS. Yeah, so i think the problem really blows up.
Add Text Shadows as Workaround
one of the hack fix is to add text shadows when you do dark theme, like this
body { background-color:black; color:white; text-shadow:2px 2px 2px black; }
so that, page like this

which had white img bg, now at least works. else the white text disappears in ether
Search All CSS Code, on Color Value of Black or White, background, background-color, border
Check all CSS, on color value of black or white, and on property of
color
and
background-color