Background properties control fills, images, positioning, clipping, and layering.
Core properties
background-colorbackground-imagebackground-repeatbackground-positionbackground-size
Pitfall
Large background images can hurt performance. Compress assets and avoid decorative megabyte-heavy patterns.
Rendered output
Background layering can communicate hierarchy without extra markup.
Important interview questions and answers
- Q: Why avoid fixed background images on mobile?
A: They can cause jank and poor scrolling performance. - Q: What does
background-size: coverdo?
A: Scales image to cover container, potentially cropping edges. - Q: Best fallback for unsupported gradients?
A: Set a solidbackground-colorfirst.
Pitfall: Check cascade order—author stylesheet loses to inline styles and !important surprises.