Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Colors & Color Functions | CSS Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. CSS Course

Lesson 7 of 50

·css

Colors & Color Functions

8 mins

Course progress14%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • Prefer HSL/HSLA for easier hue‑adjustments.
  • `rgba` and `hsla` let you create semi‑transparent layers.
  • Use CSS variables for themeable color systems.

CSS supports many color formats:

  • Hex – #ff6600
  • RGB – rgb(255,102,0)
  • RGBA – rgba(255,102,0,0.8) (adds opacity)
  • HSL – hsl(30,100%,50%)
  • HSLA – 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).


Example: Dark‑mode friendly colors

: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); }
}
Make it stickPractice what you've learned1 quiz · 6 practical tests · Optional activities from CSS CourseBrowse activities
Previous lessonBox‑Sizing PropertyContinue to lesson 8Typography BasicsBack to CSS Course curriculum