Nearby lessons

7 of 19

🖼️ CSS Background Properties

🎨 What are CSS Background Properties?

CSS Background Properties let you control the appearance of an element's background, including color, images, positioning, repetition, and sizing. These properties help create visually rich layouts and user experiences.

📋 Background Color

The background-color property sets the background color of an element using a color name, HEX, RGB, RGBA, or HSL format.

Example02
🎨Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🖼️ Background Image

The background-image property sets an image or gradient as the background of an element.

Example03
🎨Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🔁 Background Repeat

The background-repeat property controls whether and how a background image is repeated.

Example04
🎨Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

📌 Background Attachment

The background-attachment property determines if the background scrolls with the content or stays fixed.

Example05
🎨Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🎯 Background Position

The background-position property sets the starting position of a background image.

Example06
🎨Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

📏 Background Size

The background-size property defines the size of the background image.

Example07
🎨Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

📝 Background Shorthand

The background shorthand allows combining background properties in one line.

Example08
🎨Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🧠 Test Your Knowledge

5 Questions
Progress: 0 / 5