31
loading...
This website collects cookies to deliver better user experience
filter: invert(100%)
on the body but it would literally invert everything, including images and emojis. I was about to give up on it before I came across Jim Nielsen’s post on the color-scheme
property which tells the browser what color schemes a site (or element) supports and changes the default color based on the user’s preferences. To use it, you just need to specify the color-scheme
property on the :root
element.:root {
color-scheme: light dark;
}
light
or dark
as well as apply the color-scheme
property to a specific element. In some environments (like email), you can also apply a <meta name="color-scheme">
tag.The light and dark color schemes don’t represent an exact color palette (such as black-and-white), but a range of possible palettes. To guarantee specific colors, authors must specify those colors themselves. Note also that, consequently, pairing default or colors with author-specified colors cannot guarantee any particular contrast level; it might be necessary to set both foreground and background colors together to ensure legibility.