CKTIS / CSS
CSS custom properties and themes
Custom properties store values consumed by var(). The cascade and inheritance let you share design tokens and override them locally, for example to create a dark theme.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
--token: value;
property: var(--token);
property: var(--token, fallback);A custom property has a name starting with --, such as --ink. Names are case-sensitive: --ink and --Ink are different. var(--ink) substitutes its value into another property's value; it does not create selectors or property names.
Unregistered custom properties participate in the cascade and inherit. Put shared tokens on :root and theme overrides on a container. Descendants inherit the overridden values unless they have their own declarations. In the example, .dark changes the tokens while the .card rule stays shared.
var(--space, 16px) uses its fallback when the token is missing or has the guaranteed-invalid value, for example because of a dependency cycle. It does not check an existing token against the destination property: --ink: 16px will not activate the fallback in color: var(--ink, black). The declaration becomes invalid at computed-value time; for color, this means inheritance, not returning to an earlier declaration in the cascade.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Custom properties</title>
<style>
:root {
--surface: white;
--ink: black;
}
.dark {
--surface: black;
--ink: white;
}
.card {
background-color: var(--surface);
color: var(--ink);
padding: var(--space, 16px);
}
</style>
<div class="card">Light</div>
<section class="dark">
<div class="card">Dark</div>
</section>
</html>Result
Light: black text on white; Dark: white text on black. Both cards: 16px padding on every side.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.