skip to Main Content

I have one html page named HOME.HTML with this code:

 <!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>Home</title>
 </head>
 <style>
       *{
          margin: 0px;
          padding: 0px; }
        body { width: 100vw;
           height: 100vh; 
        background: url('telahome2.jpg') no-repeat top center ; 
        }
 </style>

 <body>

 </body>
 </html>

the image file telahome2.jpg is in the root directory but its not loading.
Thanks by any help.

2

Answers


  1. Check your filename for types. Your code is correct.

    Login or Signup to reply.
  2. if your image is in the same folder just write it like this background-image: url(/telahome2.jpg); and don’t write "no-repeat top center" these on the same line. you have to write them line this

    body {
      width: 100vw;
      height: 100vh;
      background-image: url(/telahome2.jpg);
      background-position: center;
      background-repeat: no-repeat;
      background-size: cover;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search