Browser doesn't find images from HTML when running on local host

31 views Asked by At

I am developing my site and running on the local host now on windows computer. I want to set a background image for the page but when I run the server it throughs a message that the image is not found. The image is located in the same directory where the html is. This is a really simple thing but I am straggling with it from early morning. Looked in all the forums but nothing helped so far.

I tried changing the file path as relative/absolute. But no result. No mistake in the file name or path.

body {
            background-image: url("background.jpg")
        }
1

There are 1 answers

1
Tolgahan Dayanıklı On BEST ANSWER

Try this:

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

Note: I assume that you are using Django because of the tags, it is better to re-locate your static image files under the directory public or static which is publicly accessible from the web server.