HTML & CSS · Middle · Question 59 of 75
How do you follow the user's system dark theme in plain CSS?
@media (prefers-color-scheme: dark) {
:root { --bg: #111; --text: #eee; }
}- ✓Correct answer: With the
prefers-color-schememedia feature, usually redefining CSS variables - 2With
@media (theme: dark) - 3Only with JavaScript
Explanation
If the site also has a manual theme toggle, combine it with a class or data-theme attribute that takes priority over the media query.