From the course: CSS: Variables and Fluid Layouts
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Configure CSS custom properties - CSS Tutorial
From the course: CSS: Variables and Fluid Layouts
Configure CSS custom properties
- [Female narrator] Now that you've heard a little background about custom properties, let's see how to configure them and use them in your CSS. Declaring a variable is really easy. First of all, configure your CSS declaration with a selector and a declaration body, just as you always do. Notice here I'm using the pseudo-class of root. This is a more specific selector than the usual HTML element selector, which may be an advantage. The root selector also selects the full root of the document where the HTML elements selector may not do that, and that may matter especially if you're manipulating these values with JavaScript. By using the root selector, you're making any variable declarations here available to your full document, wherever you'd like to call on the variables. So essentially anything that's here is scoped globally. Inside of the declaration body, declare your variables starting with a double hyphen…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
CSS custom properties overview3m 44s
-
(Locked)
Configure CSS custom properties2m 26s
-
(Locked)
CSS custom properties and inheritance4m 27s
-
(Locked)
CSS custom properties and Sass variables3m 37s
-
(Locked)
Using Sass variables3m 25s
-
(Locked)
Challenge: Add custom properties to type scale2m 27s
-
(Locked)
Solution: Add custom properties to type scale2m 20s
-
(Locked)
-
-
-