Dark Mode in One Line of Code!
Dark mode has seemingly become the desired visual mode for websites and mobile apps alike. Dark mode is easier on the eyes, especially for those like me who like to burn the midnight oil by coding and reading tutorials. Unfortunately not all websites offer dark mode, so it's up to me to remedy the situation.
Though it's not a true "dark mode", you can use CSS' filter
to create dark mode of your own:
html {
filter: invert(1);
}
Inverting colors completely via 1
will make that light-themed website much more comfortable on your eyes. It's important to realize that developers shouldn't consider this a long-term solution, as it's a quite lazy remedy and doesn't lend well to branding.
CSS filter support recently landed within WebKit nightlies. CSS filters provide a method for modifying the rendering of a basic DOM element, image, or video. CSS filters allow for blurring, warping, and modifying the color intensity of elements. Let's have...
When you say or read "HTML5", you half expect exotic dancers and unicorns to walk into the room to the tune of "I'm Sexy and I Know It." Can you blame us though? We watched the fundamental APIs stagnate for so long that a basic feature...
I've never met a person that is "ehhhh" about XHTML/javascript tooltips; people seem to love them or hate them. I'm on the love side of things. Tooltips give you a bit more information about something than just the element itself (usually...
I recently received an email from a reader who was really impressed with Block Clickable, a jQuery script that took the link within a list item and made the entire list item clickable. I thought it was a neat script so I...
Nice trick !
I would add exactly the same on all images with
Then you are even closer to a dark mode ;)
oh god no
I just tried it here and it worked, Thanks for the info.
here is the code I used:
document.querySelector('html').style.filter = 'invert(1)'
I love filter for this! You can also make the inversion less harsh by adding to the filter list:
Never EVER use this trick other than for a quick preview.
CSS filters on large areas are really bad for scrolling performance.
This isn’t quite dark mode. This is just an invert which makes images look like crap. Still, neat trick.
Thanks