CSS Backgrounds

CSS Tutorial

CSS Backgrounds

CSS background properties are used to control the background color, image, repeat, position, and size of elements.


1️⃣ background-color

Sets the background color.



2️⃣ background-image

Sets a background image.



3️⃣ background-repeat

Controls repeating of the image.


Options:
repeat, repeat-x, repeat-y, no-repeat


4️⃣ background-position

Sets the starting position of the image.


Options:
left, right, top, bottom, center, or x y values


5️⃣ background-size

Controls the size of the image.


Options:
auto, cover, contain, or pixel/percentage values


6️⃣ background-attachment

Controls scroll behavior.


Options:
scroll, fixed, local


7️⃣ Shorthand (All in One Line)



📌 Full Example


You may also like...