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.

CSS Gradients Deep Dive | CSS Basics to Advanced lesson | BraveProgrammer
  1. Courses
  2. /
  3. CSS Basics to Advanced

Lesson 16 of 50

·css

CSS Gradients Deep Dive

8 mins

Course progress32%

What you'll learn

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

3 points
  • Gradients accept any CSS color format, including `rgba` and `hsl`.
  • `conic-gradient` is great for pie‑chart‑like visuals.
  • Gradients can be animated by moving `background-position` or changing `color‑stop` positions.

Gradients are vector‑based colour transitions that scale perfectly on any screen. They can replace raster images for UI accents, loading placeholders, and decorative fills.

Types of Gradients

TypeSyntaxTypical Use
linear-gradientlinear-gradient(to right, #ff7e5f, #feb47b)Buttons, banners, background bars.
radial-gradientradial-gradient(circle at center, #e0eafc, #cfdef3)Soft spotlights, badge backgrounds.
conic-gradient (CSS 4)conic-gradient(from 90deg at 50% 50%, #ff0, #f0f, #0ff)Pie‑chart slices, loading spinners.

Animated Gradient Background (Shimmer Effect)

@keyframes hueShift {
  0%   { background-position:0% 50%; }
  50%  { background-position:100% 50%; }
  100% { background-position:0% 50%; }
}
.banner {
  background:linear-gradient(270deg, #ff6b6b, #f7d794, #5f27cd);
  background-size:600% 600%;           /* large canvas for animation */
  animation:hueShift 12s ease infinite;
}

By moving the background‑position, we get an infinite colour sweep without animating individual colour stops, which is far cheaper for the GPU.


Tip – Use background-size for smooth looping

If the gradient repeats seamlessly, set background-size to a multiple (e.g., 200%) so the animation loops without a visible jump.

Browser Compatibility

All modern browsers support linear and radial. conic-gradient is now supported in Chrome 112+, Safari 16.4+, and Firefox 80+. For older browsers, fall back to a solid colour.

Make it stickPractice what you've learned1 quiz · 6 practical tests · Optional activities from CSS Basics to AdvancedBrowse activities
Previous lessonBackgrounds – Images & GradientsContinue to lesson 17CSS FiltersBack to CSS Basics to Advanced curriculum