CSS background
CSS Background background
Description
Background is a shorthand property for setting the background style of an element.
Possible Values
Background is a shorthand property that represents the following. The values vary depending on the actual property.
- background-color – Sets a solid color for the background, margin, and border of an element.
-
background-image – Defines the position of an image to be placed in the element’s background.
-
background-repeat – Sets the repeat direction of an image in an element’s background.
-
background-attachment – Sets the attachment state of any image in an element’s background.
-
background-position – Sets the position of the original image in the element’s background.
-
background-clip – Specifies the area where a background image is drawn.
Applies to
All HTML elements.
DOM syntax
object.style.background = "Value according to the used property";
Example
<html>
<head>
</head>
<body>
<p style = "background:url(https://geek-docs.com/static/https://coder-cafe.com/wp-content/uploads/2025/09/logo.png) repeat fixed;">
This paragraph has fixed repeated background image.
This paragraph has fixed repeated background image.
This paragraph has fixed repeated background image.
This paragraph has fixed repeated background image.
</p>
</body>
</html>
It will produce the following result −