To define a CSS variable, use the -- prefix followed by a name of your choice, and assign it a value. You can reference the variable using the var() function.
Here's an example:
css
:root {
/* Backgrounds */
--primary-background: #faf8ef;
/* Colors */
--primary-text-color: #776e65;
}
In this example, CSS variables are defined inside the :root pseudo-class, making them globally accessible. Each variable begins with -- (e.g., --primary-background or --primary-text-color) and is assigned a value.
With this approach, you can easily update website colors by modifying the variable values.