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.

Backgrounds – Images & Gradients | CSS Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. CSS Course

Lesson 15 of 50

·css

Backgrounds – Images & Gradients

10 mins

Course progress30%

What you'll learn

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

3 points
  • `background-size:cover` fills the container while preserving aspect ratio.
  • Multiple backgrounds are comma‑separated and are layered from left to right.
  • CSS gradients are resolution‑independent and lightweight.

Background properties give a lot of power:

  • background-image – URL, gradients (linear-gradient, radial-gradient).
  • background-size – cover, contain, or explicit dimensions.
  • background-position – center, top left, percentages.
  • background-repeat – no-repeat, repeat-x, repeat-y.
  • background-attachment – fixed for parallax effects.

Example: Gradient overlay on an image

.hero {
  background-image: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4)), url('hero.jpg');
  background-size: cover;
  background-position: center;
  color:#fff;
  padding:4rem 2rem;
}
Make it stickPractice what you've learned1 quiz · 6 practical tests · Optional activities from CSS CourseBrowse activities
Previous lessonVisibility & OpacityContinue to lesson 16CSS Gradients Deep DiveBack to CSS Course curriculum