@midsunv4mpyr a var is a variable, a variable in code is a kind of container fer certain types of data so u can store CSS colors in them like how @Chillton showed! usually u put those variables in a :root selector.
Another thing: why ur color might be overwritten or not applying could be bc of a lot of diff reasons:
- The selector is wrong. Example: U r trying to get a
paragraph but u accidentalyl wrote it wrong or the class wrong.
- The specificity isnt enough, in CSS u have selectors n hierarchy, next to that CSS stands fer Cascading Stlyesheets, meaning it cascades in order of the way u write ur code so be aware of that!
Expanding on the specificity selectors cuz its best practice to be more specific rather than using the easy yet problematic keyword !important, what i mean w specificity selectors is how SPECIFIC ur writing ur selector. Say fer example u want to make this paragraph element that sits in a div with the class "heading", the color purple.
U could write it like this p { color: purple; }, but that could be very easily overwritten if its not specific enough. Lets add in the div that it sits in! div > p { color: purple; }. We could get even MORE specific: div.heading > p { color: purple; }
Hope this helps bro, if not feel free to IM me ;]
(This is coming from an actual developer who has studied in skool n has an actual job)