How do CSS Custom Properties cascade, and how does this affect their scope?

Instruction: Discuss the cascading nature of CSS Custom Properties and its implications on their scope within a document.

Context: This question evaluates the candidate's understanding of CSS Custom Properties (variables), focusing on their cascading nature and scope.

Updated

Official answer available

Read the opening below, then unlock the full answer and practical guidance.

An ordinary unregistered custom property is a property on an element. Its declaration participates in the cascade on that element; if no declaration supplies its value, it normally inherits the parent's computed value. A declaration on a descendant can replace an inherited value without being more specific than the ancestor's selector.

This differs from a lexical variable shared across a stylesheet...

Related Questions