How is order of precedence established with CSS variables?
I have a CSS library that is themeable by way of CSS variables. I set the variables in the library like so:
:root,
:host {
--my-color: #ffffff
}
Then in their own CSS code, the user can override this value:
:root,
:host {
--my-color: #000000
}
This seems to work, but I'm wondering why it works. The selector is the same in both cases, so I'm not sure why it's using the variable.
Also, is there something I can do to ensure that in all cases the latter variable always gets chosen?