HTML CSS JavaScript SEO Python Posts Privacy About Contact

CSS Backgrounds

The CSS background properties are used to add background effects for elements.

CSS background properties let you style the background of any element with colors, images, gradients, and control their position and repeat behaviour.

Try It — All Background Types

Preview

Background Properties Reference

PropertyWhat it doesExample
background-colorSolid fill colorbackground-color: #f0f0f0
background-imageImage or gradientbackground-image: url(...)
background-repeatControls image repeatno-repeat, repeat-x, repeat-y
background-positionWhere to place backgroundcenter, top right
background-sizeScale the backgroundcover, contain

Tip: Use background: linear-gradient(to right, #color1, #color2) to create smooth gradient backgrounds without any images!