concept

theme-architecture — CSS reference

A theme architecture separates semantic roles from their palette values. Define paired foreground and background tokens at a shared scope, let components consume roles, and vary the role values in a theme or preference context. Honor forced colors rather than replacing it globally. Check contrast for each actual pairing, including focus and states.

Formal Syntax & Structure

css syntaxcss
color-scheme: light dark; --surface: …; --text: …;

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS accessible theme lab</title><style>body {margin:0} .sample {height:12px;background:#006050}html{color-scheme:light dark;--surface:#fff;--text:#111} @media(prefers-color-scheme:dark){html{--surface:#121212;--text:#eee}} article{background:var(--surface);color:var(--text);padding:12px}</style><body><article id="a">Themeable content</article></body></html>
CSS Reference