Why does prefers-color-scheme need duplication of styles?
I was watching KP's video on using dark / light themes:
https://www.youtube.com/watch?v=zFFuV_vXNhY&t=36s
And it works nicely, but it bothers me that the styles are duplicated in :root definitions as well as the theme switcher ":has" definition.
Why is the duplication needed if I have selected the theme using color-scheme: [dark|light] declaration? It seems to override behaviour for system styles, but not anything I've defined.
G
https://www.youtube.com/watch?v=zFFuV_vXNhY&t=36s
And it works nicely, but it bothers me that the styles are duplicated in :root definitions as well as the theme switcher ":has" definition.
Why is the duplication needed if I have selected the theme using color-scheme: [dark|light] declaration? It seems to override behaviour for system styles, but not anything I've defined.
G
YouTubeKevin Powell
Looking to step up your CSS game? I have free & premium courses
https://kevinpowell.co/courses?utm_campaign=general&utm_source=youtube&utm_medium=lightdarkfix
Links
Finished example: https://codepen.io/kevinpowell/pen/KKEevOp
More in-depth video on creating a light/dark toggle: https://youtu.be/QtuLN0lNb-Y
Timestamps
00:00 - Introduc...
00:00 - Introduc...

