1body {
2 background-color: black;
3 color: white;
4}
5
6@media screen and (prefers-color-scheme: light) {
7 body {
8 background-color: white;
9 color: black;
10 }
11}
1@media (prefers-color-scheme: dark) {
2 body {
3 background-color: black;
4 color: white;
5 }
6}
1<!DOCTYPE html>
2<html>
3<head>
4<style>
5body.dark-mode {
6 background-color: black;
7 color: white;
8}
9
10@media screen and (prefers-color-scheme: light) {
11 body.dark-mode {
12 background-color: unset;
13 color: unset;
14 }
15}
16</style>
17</head>
18<body class="dark-mode">
19
20<p>Text</p>
21
22</body>
23</html>