Table of Contents
CSS Back Ground properties
- The background properties are shorthand property for html element:
Background-color
- It is used for element background color like red, green, yellow etc.
- The background of an element is the total size of the element, including padding and border(but not the margin).
Example
<!DOCTYPE html>
<html>
<head>
<style>
h2,p{
background-color: yellow;
}
</style>
</head>
<body>
<h2>My first page.</h2>
<p>Hello Nielitbhu.com This is an example of CSS background-color.</p>
</body>
</html>
Background-image
- Using this short hand property set the background image.
- By default, a background-image is placed at the top-left corner of an element, and it repeated both vertically and horizontally.
Example
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url('https://nielitbhu.com/paper.jpg');
margin-left: 150px;
}
</style>
</head>
<body>
<h1>Hello Nielitbhu.com</h1>
<h2>Example of CSS Background-image </h2>
</body>
</html>