Skip to content
CSS·Advanced·Conceptual·1 min read

What's the practical difference between overriding a custom property on :root versus on html?

Short interview answer

:root refers to the document's root element, the html element in an HTML document, so overriding on :root and on html target the same element and produce identical inheritance behavior; the practical difference is specificity, since :root as a pseudo-class has the specificity of a class selector while html is a type selector with lower specificity.

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Custom properties and theming

Related questions