![]() |
VOOZH | about |
The CSS background defines the area behind an element’s content and can include colors, images, or both. It provides control over how these backgrounds appear and behave.
You can try different types of background here:
The CSS Background is a shorthand property for the following:
The background-color property in CSS sets the background color of an element. It can accept a color name (e.g., "red"), HEX value (e.g., "#ff0000"), or RGB value (e.g., "rgb(255, 0, 0)").
body {
background-color:color name
}
The background-image property in CSS is used to set an image as the background of an element. By default, the image is repeated to cover the entire element unless specified otherwise.
body {
background-image : link;
}
The background-repeat property in CSS specifies how the background image is repeated. By default, the image repeats both horizontally and vertically. You can control the repetition by specifying values such as repeat-x, repeat-y, or no-repeat.
Syntax:
body {
background-image:link;
background-repeat: repeat:x;
}
The background-attachment property in CSS specifies how the background image behaves when the user scrolls the page. By setting the value to fixed, the background image stays in place while the content of the page scrolls.
Syntax:
body {
background-attachment: fixed;
}
The background-position property in CSS is used to set the starting position of the background image within the element. You can use values like top, left, center, or specify exact pixel/percentage values to position the image.
body {
background-repeat:no repeat;
background-position:left top;
}
1. background-origin
The background-origin property sets the starting position of a background image relative to the element’s box.
Syntax:
body {
background-image: url('https://via.placeholder.com/300');
background-origin: padding-box;
}
2. background-clip
The background-clip property defines how far the background (color or image) extends within an element.
Syntax:
body {
background-image: url('https://via.placeholder.com/300');
background-clip: content-box;
}