0

I just started learning front end using html & css and i just want to follow a tutorial from youtube and i have problems right from the start. I'm trying to put a background img for the website, but it dosen't show up and i found that nothing works on this div, even if i just put a background color. My code looks like this:

<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>My web</title>
    <link rel="stylesheet" href="style.css">
</head>
<style>


*{
    margin: 0;
    padding: 0;
}

.container{
    width: 100vh;
    height: 100%;
    background-image: url(Images/background.png);
    background-position: center;
    background-size: cover;
    padding-left: 5%;
    padding-right: 5%;
    box-sizing: border-box;
    position: relative;
    
}

</style>
<body>
    
    <div class="container">

    </div>
</body>
</html>```
  

 


2 Answers2

0

It is because the container div is completely empty. Try filling it with something, like a paragraph element or an image.

0

First place the style tag inside the head tag. https://www.w3schools.com/tags/tag_style.asp

Then make sure your image link to the background image is correct. NOTE: if the folder is named images and you use Images with a capital "I" it will not work.

Also try height 100vh instead of 100%

KJEK-Code
  • 695
  • 1
  • 5
  • 10