:root { --light-code-background: #FFFFFF; --dark-code-background: #1E1E1E; } @media (prefers-color-scheme: light) { :root { --code-background: var(--light-code-background); } } @media (prefers-color-scheme: dark) { :root { --code-background: var(--dark-code-background); } } body.light { --code-background: var(--light-code-background); } body.dark { --code-background: var(--dark-code-background); } pre, code { background: var(--code-background); }