The CSS background properties are used to add background effects for elements.
The background shorthand CSS property sets all background style properties at once, such as color, image, origin and size, or repeat method.
The background property in CSS allows you to control different aspects of this background, like setting the color, adding an image, and deciding how that image repeats or is positioned. It combines several settings into one line for easier styling.
The background-color property specifies the background color of an element.
Example:
The background color of paragraph is set like this:
p
{
background-color:red;
}
The background-attachment CSS property sets whether a background image's position is fixed within the viewport or scrolls with its containing block.
Background Property | Description |
---|---|
background-color | Defines the background color of an element using color names, HEX, or RGB values. |
background-image | Adds one or more images as the background of an element. |
background-repeat | Specifies how the background image should be repeated-horizontally, vertically, or not at all. |
background-attachment | Controls the scrolling behavior of the background image, making it fixed or scrollable with the page |
background-position | Determines the initial position of the background image within the element. |
background-origin | Adjusts the placement of the background image retrive to the padding, border, or content box. |
background-clip | Sets how far the background( color or image) should extend within an element (e.g., to the padding or border) |