HTTP/2 200
date: Sun, 12 Oct 2025 23:21:16 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
vary: Accept-Encoding
vary: Accept-Encoding
referrer-policy: strict-origin-when-cross-origin
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
strict-transport-security: max-age=31536000
link:
; rel="https://api.w.org/",
; rel="alternate"; title="JSON"; type="application/json", ; rel=shortlink
cache-provider: CLOUDWAYS-CACHE-DC
last-modified: Sun, 12 Oct 2025 23:21:16 GMT
cache-control: max-age=0, s-maxage=2592000
expires: Sun, 12 Oct 2025 23:21:16 GMT
age: 0
x-cache: MISS
cf-cache-status: DYNAMIC
content-encoding: gzip
cf-ray: 98da5521fcb825e0-BLR
Advantages to Native CSS Variables | CSS-Tricks
I tend to think variables are best left to a preprocessing step, but there are some distinct things that having them directly in CSS can do:
Daniel Imms:
[they] can change at runtime, allowing the implementation of things like theming to be done more elegantly.
i.e. change the value of a variable on a live, rendered web page and see the changes reflected everywhere that uses that variable.
Peter Gasston:
you can set the value through the setProperty()
method on the style object
Which makes #1 possible and opens up cool possibilities.
They can be scoped to an element. So perhaps you could set variables representing color to theme a site, but override them at a component level to apply different themes in smaller places as needed.
Direct Link →