# CSS Backgrounds

# **CSS Backgrounds**

## 👉 **CSS Backgrounds**

The `background-color` property specifies the background color of an element.
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668958679793/1Z1ohfAq3.png align="left")

## 👉 CSS background-image

The `background-image` property specifies an image to use as the background of an element.
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668958698652/jwzY5YUde.png align="left")

## 👉 **CSS Background Image Repeat**

By default, the `background-image` property repeats an image both horizontally and vertically.

Showing the background image only once is also specified by the `background-repeat`
 property:
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668958719927/wYFjurkR5.png align="left")

👉 CSS background-repeat Property

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668958742793/T3YlVNXyA.png align="left")

## 👉 **CSS background-attachment Property**

The `background-attachment` property specifies whether the background image should scroll or be fixed (will not scroll with the rest of the page):

**CSS background-attachment Property👇**
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668958767997/16IhBUJf2.png align="left")

Example of fixed 👇

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668958795259/enEJelE7O.png align="left")

Example of scroll 👇
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668958820838/45MATV5MS.png align="left")

## **CSS background-position Property**

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

Note**:-**

By default, a [`background-image`](https://www.w3schools.com/cssref/pr_background-image.asp) is placed at the top-left corner of an element and repeated both vertically and horizontally.

**Property Values of background-position👇**


![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668958842083/0Iol3AdDv.png align="left")

Example of position center👇
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668958864089/CFbeHFJnp.png align="left")

Example based on  horizontal and vertical position**👇**
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668958885874/zHNss7Rfg.png align="left")

Example of right center**👇**
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668958908742/b3BcE_8NH.png align="left")

## **CSS background-size Property 👇**

The `background-size` property specifies the size of the background images.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668958933169/gwWdTOVIf.png align="left")

Example of length property👇
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668958958864/pr5UMk5lF.png align="left")

We can also use two images in background.

Example👇
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668958988789/AVeGR3Hia.png align="left")

-----------------------------------------------------------------------------------------------
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1666336375150/5HqI8zNVh.png align="left")> 
Download our HTML & CSS Visual Treat! ebook Here: 
[Click here](https://codemarch.gumroad.com/l/hxazr)

