Using Media Queries for Dark Mode in CSS


Detect user preference for dark mode using media queries.

Source Code

@media (prefers-color-scheme: dark) {
    body {
        background-color: #121212;
        color: #e0e0e0;
    }
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments