#ISCSS Meetup #1, see https://www.meetup.com/IS-CSS/events/250102141/
A talk about native CSS Variables, covering examples, comparison with preprocessor alternatives, nuances, advantages and limitations.
2. ● The property is an identifier that defines
which feature is considered
● The value describe how the feature must be
handle by the engine
● A property and value pair is called a
declaration
● Declarations are grouped in blocks
● Each block is preceded by a selector
CSS Syntax
3. ● CSS custom properties (variables)
● Property names that are prefixed with --, like
--example-name, represent custom properties
that contain a value that can be reused
throughout the document using the var()
function
● Are subject to the cascade and inherit their
value from their parent
CSS Variables
15. ● currentColor was the first CSS Variable
● Are subject to the cascade and inherit their value from their parent
● Can provide one or more fallback value/s
● Are case sensitive
● Are dynamic, can be changed in different scopes and at runtime
● Can be used in combination with calc(), SVG, @media, @keyframes animations, etc.
Conclusions: CSS Variables
16. Can I use?
CSS Variables
(Custom Properties)
Permits the declaration and usage of
cascading variables in stylesheets
87.73% APR 2018
body {
--bg-color: #150C55;
background-color: pink;
}
@supports (background-color: var(--bg-color)) {
body {
background-color: var(--bg-color);
}
}