user3227564
user3227564

Reputation: 23

CSS Background not working

I am trying to add a background using the following, placed inside custom.css:

}

body {
background-image: url("img/background.jpg");
}

custom.css is in folder HTML/css

background.jpg is in folder HTML/img

What should I do so that the background works? Right now it doesn't appear at all.

Upvotes: 0

Views: 51

Answers (3)

Vinayak
Vinayak

Reputation: 425

Please use :

body{
   background-image: url('../img/background.jpg');
}

Upvotes: 0

Sumner Evans
Sumner Evans

Reputation: 9157

Go up a level with your URL selector using ..:

background-image: url("../img/background.jpg");

That will go up a level (to the HTML folder) and then find the background.jpg file in the img folder.

Upvotes: 2

NStorm
NStorm

Reputation: 2528

It's because your 'img' folder is in a different directory to your 'css' folder.

Try

background-image: url("../img/background.jpg");

Upvotes: 0

Related Questions