Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Background Image Not Displaying

I have an HTML file with a subdirectory called img with an image called debut_dark.png. In my CSS file, I have:

body {      background: url(/img/debut_dark.png) repeat 0 0; } 

The HTML file has the body tag and does include the CSS file appropriately. I know for sure the CSS file is included properly as everything else is formatted properly.

The background image is not getting displayed, I am only seeing a white background. Any ideas how to fix this, or even how to debug it?

like image 304
darksky Avatar asked Dec 25 '12 09:12

darksky


People also ask

Why does my CSS background image not showing up?

Make sure the image path is set correctly in the background-image url. Once you have made sure that your CSS file is linked correctly, also check that the image itself is set correctly. Again, you will want to open your code inspector in the browser to check.

Why is my Div background image not showing?

you have to change your path background-image: url('/ximages/websiteheader1. png') ; TO background-image: url('ximages/websiteheader1. png') ; actually, remove the first / from the path of the image.


Video Answer


2 Answers

According to your CSS file path, I will suppose it is at the same directory with your HTML page, you have to change the url as follows:

body { background: url(img/debut_dark.png) repeat 0 0; } 
like image 159
SaidbakR Avatar answered Sep 28 '22 07:09

SaidbakR


You should use like this:

          body {              background: url("img/debut_dark.png") repeat 0 0;         }          body {              background: url("../img/debut_dark.png") repeat 0 0;         }          body {              background-image: url("../img/debut_dark.png") repeat 0 0;         }  

or try Inspecting CSS Rules using Firefox Firebug tool.

like image 43
Surinder ツ Avatar answered Sep 28 '22 08:09

Surinder ツ