Yes, you can use the filter property to invert the colors of all elements except for images. Here's an example:
@media (prefers-color-scheme: dark) {
body {
filter: invert(1);
}
img {
filter: invert(0);
}
}
This will invert the colors of all elements on the page when the user's device is in dark mode, except for images which will remain unchanged. The invert(1) value in the body rule inverts all colors, while the invert(0) value in the img rule resets the filter for images.
You can also use the not selector to exclude specific elements from the filter, like this:
@media (prefers-color-scheme: dark) {
body *:not(img) {
filter: invert(1);
}
}
This will invert the colors of all elements except for images.