1. css
  2. /background

CSS Background Property

.my-element {
  background: #333; /* Sets the background color to dark gray */
  background: url("my-image.jpg"); /* Sets the background image to "my-image.jpg" */
  background-repeat: repeat-x; /* Sets the background image to repeat horizontally */
  background-position: top center; /* Sets the background image to be positioned at the top center of the element */
}

In the example above, we are setting the background property of the .my-element class to a dark gray color and a background-image. We are also using the background-repeat and background-position properties to control how the background image is displayed.

The background property is a shorthand property that allows you to set multiple background-related properties in a single declaration. You can use it to set the background color, background image, background repeat, and background position, as well as other properties such as background size and background attachment.

Here is an example of using the background property to set multiple values:

.my-element {
  background: #333 url("my-image.jpg") repeat-x top center;
}

In the example above, we are setting the background color to dark gray, the background image to "my-image.jpg", the background repeat to repeat horizontally, and the background position to the top center of the element, all in a single declaration using the background property.

You can learn more about the background property and its possible values on the Mozilla Developer Network.