Background-position Property
This property is used to set the image to a particular position.
Syntax :
body {
background-repeat:no repeat;
background-position:left top;
}
Example: This example shows the use of the background-position property in CSS.
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image:
url(
"https://media.w3wiki.org/wp-content/cdn-uploads/20190417124305/250.png");
background-repeat: no-repeat;
background-position: center;
}
</style>
</head>
<body>
<h1>w3wiki</h1>
</body>
</html>
Output:
CSS Background
The CSS background property is a shorthand for setting multiple background properties in one declaration, including background color, image, position, size, repeat, origin, clip, and attachment. This property is essential for customizing the visual appearance of elements.
Syntax:
css selector{
background: bgColor bgImageUrl bgPosition bgRepeat bgAttachment;
}
/*
.root{
background: white url("gfg_logo.png") center no-repeat fixed;
}
*/
Example: This example display the use of CSS background.
<!DOCTYPE html>
<html>
<head>
<style>
body {
background: lightblue url(
"https://media.w3wiki.org/wp-content/cdn-uploads/20190417124305/250.png")
no-repeat center fixed;
}
</style>
</head>
<body></body>
</html>
Output:
Contact Us