Background images can either enhance a website or make it visually overwhelming.
CSS offers various properties to manage how background images are shown.
Let’s make things clear.
The Main Backgrounds Properties and How They Work
Size:
background-size controls how large your image appears inside an element. The most common values are:
cover: Fills the entire area, cropping the image if needed. Great for banners.contain: Fits the entire image inside the element, even if there’s space left.- Or specific sizes like
100pxor50%, which give you more precise control.
What’s the common practice?
Use cover when you want full impact, in cases like hero sections. Use contain when you need the full image visible, like logos or icons.
Example:

And another version:

Repeat:
By default, background images repeat to fill the space. That’s what background-repeat does.
repeat: Tiles in both directions (default behavior).no-repeat: Shows the image just once.repeat-xorrepeat-y: Tiles horizontally or vertically only.
Repeating works best with patterns.

But for photos or larger visuals, no-repeat usually makes more sense. Otherwise, it can look chaotic fast.
Example:

And a more practical one:

Position:
You can control where the image appears using background-position.
- Values like
top left,center center, orbottom rightanchor the image inside its container. - You can also use percentages or pixel values (
50% 0or10px 20px) for more exact placement.
It’s useful when your background needs to highlight a particular part of the image, say, a face or focal object.
Example:

Pixel-based positioning:

Attachment:
background-attachment decides whether the background scrolls with the content or stays put.
scroll: The background moves as you scroll (default).fixed: The background stays in place while everything else moves.
A fixed background can give your layout a layered feel. But on mobile, it can cause performance issues.

All Together
Here’s a complete example combining all four properties:

Wrapping It All Up
Proper use of size, repeat, position, and attachment makes background images look deliberate, not accidental. Mastering them gives you the ability to design with confidence.
Good design isn’t just about how things look. It’s also about how they behave.