Dark mode with web standards
23 points by hongminhee
23 points by hongminhee
somewhat surprisingly, the blog itself doesn't seem to have a dark mode? otherwise a good tour of the current state of things
I've also discovered that the media attribute can also used for website "favicons" and it even automatically updates when the color scheme changes. I've use this in some sites I made (like this gruvbox midi visualizer)
<link
rel="icon" type="image/svg+xml" href="./icon-dark.svg"
media="(prefers-color-scheme: dark)"
/>
<link
rel="icon" type="image/svg+xml" href="./icon-dark.svg"
media="(prefers-color-scheme: dark)"
/>
*coff coff* I always notice that github doesn't do this and their icon goes out of sync until I reopen the tab *coff coff*
Such a sad state, when most examples that are standard based aren’t implemented in all engines :-/
A user might want dark mode for the UI of an application, but light mode for reading long-form text on content-heavy sites, for example
I recognize this need, but I wish there was a standardized solution to this rather than every developer cooking up their own, often unsatisfactory, scripts. It'd be nice if I could customize my Firefox toolbar to have a toggle for it, but that doesn't appear to be an option.
On the topic of dark mode, I've been wanting to get different people's opinions on the interaction of code blocks & syntax highlighting with the mode. Specifically:
Are there any standards with recommendations on this topic? What are examples of websites which do this really well (esp. of you're someone who likes switching between themes)?
Regarding your second point, I have run multiple online polls asking whether people preferred code blocks to match a page's light/dark mode, and each time got an overwhelming response in the positive. As a result, my site's CSS switches code blocks' appearance accordingly.
As a light mode heavy user, I can suggest three colorschemes that supposedly were developed to have good contrast.
I didn't know about the meta tag, I see the purpose (i.e. I'd prefer dark mode unless the author is strongly opinionated) but I'm not sure how a browser works actually implement that