Lesson 7 of 50
cssColors & Color Functions
8 mins
Course progress14%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 7 of 50
css8 mins
Keep these ideas in mind as you work through the lesson.
CSS supports many color formats:
#ff6600rgb(255,102,0)rgba(255,102,0,0.8) (adds opacity)hsl(30,100%,50%)hsla(30,100%,50%,0.7)currentColor – inherits the element’s color value.CSS 4 adds color functions like color(), lab(), lch(), and color-mod() (still experimental).
:root {
--primary: hsl(210, 60%, 50%);
--primary-dark: hsl(210, 60%, 30%);
}
body { color: var(--primary); }
@media (prefers-color-scheme: dark) {
body { color: var(--primary-dark); }
}