Skip to main content

How to add a background image in css


 

The background-image property in CSS is employed to line a picture because the background of a component . Using this CSS property, we will set one or quite one background image for a component .


By default, the image is positioned at the top-left corner of a component and repeated both horizontally also as vertically. The background image should be chosen consistent with the text color. The bad combination of text and background image could also be a explanation for poorly designed and not readable webpage.


The url() value of this property allows us to incorporate a file path to any image. it'll show the element's background. we will use multiple images or a mix of gradients and pictures for the background. If the background-image is did not load or if we are using the gradients, but they're not supported on the corresponding browser then, we will use the fallback value (the value used because the substitution) because the background color of the element.


syntax:

  1. background-image: url();  


Example:
  1. <!DOCTYPE html>    
  2. <html>    
  3. <head>    
  4. <style>    
  5. body {    
  6.   background-image: url("cat.png");  
  7.   background-color: lightgray;  
  8.   }  
  9. </style>    
  10. </head>    
  11. <body>    
  12. </body>    
  13. </html>  




output:
output will be image of cat

Comments

Popular posts from this blog

Eduford HTML and CSS dynamic website template free with source code

               For more templates please subscribe the blog and share it             For more templates please subscribe the blog and share it                    For more templates please subscribe the blog and share it           For more templates please subscribe the blog and share it           For more templates please subscribe the blog and share it                                       DOWNLOAD TEMPLATE

Website background design using HTML and CSS

         Background plays a big role in website designing. When a visitor visits a website, the background works to attract him and keep him on the website.      Website background design using HTML and CSS HTML: <!DOCTYPE html> <html lang =" en "> <head> <meta charset =" UTF-8 "> <meta http-equiv =" X-UA-Compatible " content =" IE=edge "> <meta name =" viewport " content =" width=device-width, initial-scale=1.0 "> <title> animated background </title> <link rel =" stylesheet " href =" style.css "> </head> <body> <div class =" wrapper "> <h2> Animated Background </h2> <div class =" box "> <div> </div> <div> </div> <div> </div> <div> </div>

Car garage web page design with full source code

  HTML: <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>car website design</title>     <link rel="stylesheet" href="style.css">     <link href="https://fonts.googleapis.com/css2?     family=Roboto:wght@300;400;900&display=swap" rel="stylesheet"> </head> <body>  <div class="container">      <nav>          <img src="images/menu.png">          <ul>              <li><img src="images/car_icon.png" </li>              <li>Engines</li>              <li>Tyres</li>              <li>Break</li>              <li>Gear box</li>              <li>Cooling</li>          </ul>      </nav>      <div class="con