var function
[Some information relates to pre-released product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.]
Used for custom properties where the value for var() is substituted for the value of a CSS property.
Syntax
var
(<custom-property-name> [ <declaration-value>? ])
Parameters
- <custom-property-name>
-
The name given to a custom property. Must start with two dashes, like --default-color.
- <declaration-value>
-
A list of declarations, like #3390b1. Set an optional second argument (separated with a comma) as a fallback value.
Examples
html {
--default-color: #3390b1;
}
/* More styles */
.myClass {
color: var(--default-color, blue);
}
Show: