Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Variables not work with custom property fallback values

Tags:

html

css

I am declaring a custom property in :root like below, but my color not work for me. What I am wrong?

:root {
    --color-primary: var(--color-primary, #ffc107);
}
body {
    background-color: var(--color-primary); // background color not work
}
like image 529
Epple Avatar asked May 07 '26 03:05

Epple


1 Answers

you need to declare the variable in :root like this:

:root {
    --color-primary: #ffc107;
}
like image 146
Florin Matei Avatar answered May 10 '26 14:05

Florin Matei



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!