Skip to content
Advertisement

I am getting a 404 error when attempting to load a background-image from CSS. Unsure how to proceed

I have searched through several posts regarding this same issue but none seem to resolve my problem. I am getting this 404 error in my console: index.css:1 GET http://localhost:5500/assets/css/assets/css/Battleship-Wallpaper.jpeg 404 (Not Found) I have the image saved in .jpeg format inside of my CSS folder. I am attempting to link the relative path and set the background image like so: background-image: url('assets/css/Battleship-Wallpaper.jpeg');

I have tried moving the image into different file locations within my project, as well as linking the entire filepath, to no avail. The rest of my CSS is loading just fine, here is how I am linking the CSS to my HTML: <link rel="stylesheet" href="./assets/css/index.css">. My intuition tells me that this is a problem with the server. I did not write the code for it, but I have reviewed it and have not been able to find a culprit.

The following is a snippet of the relevant HTML/CSS/JS server code.

JavaScript
JavaScript
JavaScript

In case this has anything to do with my DOM functionality, here is the relevant JS:

JavaScript

Any insight would be greatly appreciated.

Advertisement

Answer

If i check your code i see 3 different pathes:

In your entry text you write:

one time css/assets/css…jpeg
and the other one is css/assets/…jpeg

and later on in the code i see it going one folder up with the dot background-image: url(‘./assets/css/Battleship-Wallpaper.jpeg’);

Can you double check if you have a simple typing error?

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement