From the course: Modern CSS Techniques without JavaScript
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Working with the CSS light-dark() function
From the course: Modern CSS Techniques without JavaScript
Working with the CSS light-dark() function
- [Instructor] The next method we'll examine involves explicitly declaring colors for the light and the dark modes for our site using real color values and the new CSS light dark function. So let's go through all of that now. By adding the color scheme light dark here on the HTML, we've said that we're going to have two different color schemes for the site. And by default, your browser's going to make some guesses for this. For example, taking white and making it black. But we can spell out more specifically what exactly we mean by light mode and dark mode with this new light dark function. We're going to start here at root and we will include these options here. So for white, for example, we could say something like light-dark, and then we could spell out exactly what colors we want here. So white would be first, that goes with light mode, and black would be for dark mode. Likewise, for black, let us add light-dark. And so we're going to be black in light mode and white in dark mode.…
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)
What are light/dark color schemes?1m 49s
-
(Locked)
Setting up a color scheme with color-scheme3m 10s
-
(Locked)
Working with the CSS light-dark() function5m 34s
-
(Locked)
Switching from one color scheme to another without JavaScript7m 48s
-
(Locked)
Switching images to match color schemes with <picture>4m 22s
-
(Locked)
Challenge: Light/dark color schemes with SVGs3m 2s
-
(Locked)
Solution: Light/dark color schemes with SVGs2m 18s
-
(Locked)
-
-