Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

css variables not working

First, declare your variable in :root. This ensures that all scopes can access it.
You do it like so:

:root {
	--bg-color: #0F0A0A; /* Blackish */
}

Whenever you use it, wrap it in a var() function like this:

body {
	background: var(--bg-color);
}

Now it should work! I tend to forget the var() part the most.
 
PREVIOUS NEXT
Tagged: #css #variables #working
ADD COMMENT
Topic
Name
2+8 =