liveBook · Manning

CSS variable

Also called Custom Properties

A CSS custom property is an author-defined property, typically named with a leading double hyphen, whose value can be inherited and referenced in other declarations.

How 7 Manning books explain it

Web Components in Action

A CSS variable is a custom CSS property whose value can be defined and substituted throughout a stylesheet or component style.

How it is used
Uses custom properties to theme encapsulated Web Components and keep styling choices consistent across an application.
How deep it goes
Works through declarations, `var()` references, shadow-boundary use, and component-wide theme changes; does not detail CSS variable resolution internals.
Examples
Shows nested text colors, a shadow-styled component, a root-level green theme, and shared values in slider and color-picker styles.
What you can do after
Operate/configure it to change shared component styling through named CSS values and add a ponyfill when supporting IE11.

Read how Web Components in Action explains CSS variable →

CSS in Depth, Second Edition

A CSS custom property is an author-defined CSS property whose name begins with two hyphens and whose value can be substituted with the var() function.

How it is used
Reuses shared CSS values while allowing colors, spacing, and component styles to change with their context.
How deep it goes
Works through declaration, var() fallbacks, cascading overrides, palette organization, and typed registration for transitions.
Examples
Uses a shared font stack, light and dark panels, a breakpoint-dependent gap, and a hue-transitioning button.
What you can do after
Build it from scratch to centralize values, adapt components to their surroundings, and register a property for transitions.

Read how CSS in Depth, Second Edition explains CSS variable →

Vanilla Web

A CSS custom property is an author-defined property whose value can be inherited and reused in CSS declarations through the var() function.

How it is used
Uses custom properties as reusable design tokens for themes and as styling parameters for web components.
How deep it goes
Defines inheritance, scoping, overrides, and var() usage through concrete CSS and DOM examples; does not develop CSS parsing internals.
Examples
Shows theme classes changing a brand color and a star-rating component accepting color overrides through its host.
What you can do after
Build it from scratch: define shared tokens, override themes, and expose documented styling parameters on a web component.

Read how Vanilla Web explains CSS variable →

Tiny CSS Projects

A CSS custom property is an author-defined property whose value can be stored and reused in CSS through the var() function.

How it is used
Reuses profile-card styling values and form theme colors across CSS declarations.
How deep it goes
Explains declaration and `var()` syntax, descendant access, value types, and a behavioral contrast with Sass; does not explore browser internals.
Examples
Shows a profile-card palette and image size, a form’s shared error color, and contrasting CSS and Sass variable assignments.
What you can do after
Build it from scratch by defining custom properties in a CSS rule and reusing them with `var()` in styling declarations.

Read how Tiny CSS Projects explains CSS variable →

Acing the Frontend Interview

A CSS custom property is a named CSS value that can be defined, inherited, and substituted into other CSS declarations.

How it is used
Supports white labeling by separating brand styling from shared application functionality.
How deep it goes
Explains runtime changes to colors, fonts, and spacing, but defers detailed custom-property syntax and browser internals.
Examples
Uses multi-brand themes, runtime brand switching, configurable assets, and brand-specific JSON or i18n-style copy.
What you can do after
Apply it via runtime theming to support multiple branded deployments without duplicating core components.

Read how Acing the Frontend Interview explains CSS variable →

Math for Web Design

A CSS variable, also called a custom property, is a CSS property defined with a double-hyphen name whose value can be reused through var().

How it is used
Reuses design values and supports calculated spacing, typography, and theme colors without repeating values across CSS rules.
How deep it goes
Defines custom properties and works through substitution, unit compatibility, fallbacks, and calculated scales; does not explain browser internals.
Examples
Shows reusable spacing, valid and invalid unit arithmetic, a heading-size fallback, and a golden-ratio typography scale.
What you can do after
Build it from scratch: define reusable CSS values, calculate related sizes, and provide fallbacks for missing variables.

Read how Math for Web Design explains CSS variable →

Web Component Development with Modern Libraries and Tooling

A CSS property whose value can be defined and reused through a custom identifier, commonly beginning with two hyphens.

How it is used
Enables theme-wide styling, external customization of web components, and styling that responds to component properties.
How deep it goes
Works through var() fallback, shadow DOM inheritance, and slider-driven updates rather than detailing CSS variable resolution rules.
Examples
Uses a configurable paragraph color and a range slider that changes a paragraph’s font size.
What you can do after
Apply it via CSS var() and element styles to expose component styling options or update styles when component properties change.

Read how Web Component Development with Modern Libraries and Tooling explains CSS variable →

Also covered in

What to know first

Related concepts

Questions about CSS variable

What is CSS variable?

A CSS custom property is an author-defined property, typically named with a leading double hyphen, whose value can be inherited and referenced in other declarations.

Which Manning books explain CSS variable?

Web Components in Action, CSS in Depth, Second Edition, Vanilla Web, Tiny CSS Projects, Acing the Frontend Interview, Math for Web Design and Web Component Development with Modern Libraries and Tooling.

What should I know before learning CSS variable?

Manning books that teach CSS variable usually introduce CSS, JavaScript, attribute and light theme first.

What is the difference between CSS variable and sass variable?

A CSS custom property is an author-defined property, typically named with a leading double hyphen, whose value can be inherited and referenced in other declarations. A Sass variable is a named value, declared with a dollar-sign identifier, that Sass can substitute during stylesheet compilation according to scope and assignment.

What is CSS variable also called?

CSS variable is also called Custom Properties.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.