Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   
   HTML   
   CSS   
   JAVA SCRIPT   
   JQUERY   




CSS - Background Size


If we want to have a custom size for the background image, we can use the background-size property of CSS.


Using background-size for background-image


Example :



<html>
<head>
	<style>
		body {
  			background-image: url("my_image.png");
            background-repeat: no-repeat;
            background-size: 900px 500px;
  		}
	</style>	
</head>
	
<body>
	<p> 
		This is the first paragraph.
	</p>
</body>
</html>


Output :




In the above example, we have used the background-size property to set a custom size for the background image. Where 900px is the width and 500px is the height of the image.


<style>
	body {
		background-image: url("paper.gif");
		background-repeat: no-repeat;
		background-size: 900px 500px;
	}
</style>