Advertisement
Google Ad Slot: content-top
CSS Backgroud
In CSS, the background property is used to define the background styling of an element. It can be used to set a background color, image, position, and more. Here's a breakdown of how to use the background-related properties in CSS:
| Background Format | Description |
|---|---|
| Background Color | Sets the background color of an element. |
| Background Image | Sets an image as the background of an element. |
| Background Repeat | Controls if/how the background image is repeated. |
| Background Position | Sets the position of the background image. |
| Background Size | Specifies the size of the background image. |
| Background Attachment | Determines if the background image scrolls with the page or stays fixed. |
| Background Shorthand | You can combine multiple background properties into a shorthand property. |
Background Color:
Sets the background color of an element.
Syntax:
background-color: color | transparent | initial | inherit;
Background Image:
Sets an image as the background of an element.
Syntax:
background-image: url('url') | none | initial | inherit;
Background Repeat:
Controls if/how the background image is repeated.
Syntax:
background-repeat: repeat | repeat-x | repeat-y | no-repeat | space | round | initial | inherit;
Currently Active Property:
Background Position:
Sets the starting position of the background image.
Syntax:
background-position: value;
Currently Active Property:
Background Size:
Specifies the size of the background image.
Syntax:
background-size: auto | length | cover | contain | initial | inherit;
Currently Active Property:
Background Attachment:
Determines whether the background scrolls with the page or remains fixed.
Syntax:
background-attachment: scroll | fixed | local | initial | inherit;
Background Shorthand:
You can combine several background properties into one shorthand.
Syntax:
background = background-color | bg-image | bg-position / bg-size | repeat-style | attachment | box;