The background-image property lets you place images and gradients behind an element’s content. It is one of the most useful tools for hero sections, cards, textures, and decorative backgrounds.
01
Image Backgrounds
Use url() for files.
02
Gradients
Linear and radial fills.
03
Multiple Layers
Stack backgrounds.
04
none Default
No image by default.
05
Related Props
size, repeat, position.
06
With color
Combine with background-color.
Fundamentals
Definition and Usage
The background-image CSS property sets one or more background images for an element. The image is painted behind the content, borders, and padding according to other background properties.
You can use regular image files with url(), CSS gradients, or several layered backgrounds separated by commas. This makes it possible to build rich visual designs without extra HTML elements.
💡
Beginner Tip
Start with a simple linear-gradient(). Once that works, try background-size and background-repeat to control how the image fits the element.
Foundation
📝 Syntax
Apply background-image using a single image value or a comma-separated list:
The first background layer is painted on top. Here, the dark overlay softens the colorful gradient beneath it.
🧠 How background-image Works
1
You choose an image source
Use url(), a gradient function, or multiple comma-separated layers.
Image value
2
The browser paints it behind content
The image appears in the element’s background area, underneath text and child elements.
Rendering
3
Other background properties shape it
Use background-size, background-repeat, and background-position to control fit and placement.
Layout
=
🖼️
Rich visual backgrounds
You can create hero banners, textures, overlays, and decorative sections with CSS alone.
Compatibility
Universal Browser Support
background-image is supported in all modern browsers, including gradients and multiple background layers.
✓ Baseline · All browsers
Add background images everywhere
Chrome, Firefox, Safari, Edge, and Opera all support url(), gradients, and layered backgrounds.
99%Universal support
Google Chrome1+ · Desktop & Mobile
Full support
Mozilla Firefox3.6+ · Desktop & Mobile
Full support
Apple Safari1+ · macOS & iOS
Full support
Microsoft Edge12+ · All versions
Full support
Opera3.5+ · Modern versions
Full support
Fallback behavior
If an image fails to load, the browser can still show background-color behind the element.
💻
Broken image pathsNo image appears · Use a fallback background-color
Fallback
background-image property99% supported
Bottom line: Use background-image confidently, and always provide a sensible fallback color when using photo backgrounds.
Wrap Up
Conclusion
The background-image property is a flexible way to add visual interest to your layouts. You can use photo files, gradients, repeating patterns, and multiple layered backgrounds to build modern designs with CSS.
Start with a simple gradient, then explore url(), layered overlays, and companion properties like background-size and background-position.
Use gradients when you want reliable demo and production results
Add a fallback background-color behind photo backgrounds
Use background-size: cover; for full-area hero images
Optimize image file size for faster page loading
Keep text readable over busy background images
❌ Don’t
Confuse background-image with background-color
Forget that the first layer in a comma-separated list appears on top
Use huge unoptimized images for small elements
Rely on background images alone for important content meaning
Ignore mobile performance when using large photo backgrounds
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about background-image
Use these points when adding images and gradients to your layouts.
5
Core concepts
🖼️01
Image Backgrounds
Photos, gradients, patterns.
Purpose
🎨02
Gradients Count
Valid background images.
Values
🖼️03
Multiple Layers
Comma-separated list.
Layers
⚡04
none Default
No image unless set.
Default
🛠05
Companion Props
size, repeat, position.
Layout
❓ Frequently Asked Questions
The background-image property sets one or more background images for an element. These can be image files using url(), gradients, or a combination of layered backgrounds.
The initial value is none, which means no background image is painted on the element.
Yes. Functions such as linear-gradient(), radial-gradient(), and repeating-linear-gradient() are common background-image values.
Yes. Separate multiple background layers with commas. The first image in the list is painted on top.
background-image paints images or gradients. background-color paints a solid color behind the content. They are often used together.