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

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. CSS Basics to Advanced

Lesson 15 of 50 · css

Backgrounds – Images & Gradients

Duration: 10 mins

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;
}
Previous: Visibility & OpacityNext: CSS Gradients Deep Dive