Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "Failed to load resource: net::ERR_FILE_NOT_FOUND" when trying to load a background image

Tags:

html

css

Working on a website at the moment and want a background image for the body. I keep getting a Failed to load resource: net::ERR_FILE_NOT_FOUND. Heres my css file:

body
{
    background-image: url("C:\Users\jamie\Desktop\Work\Second Year\Web Design\CA2\Images\login.jpg");

}

Apologies if this question has been asked multiple times, but I've tried everything and have no idea whats going on, I ran developer mode and disabled cache on chrome, originally just had Images/login.jpg,I added quotes in the url() and didn't add quotes I've tried all sorts of different images in different files. Even downloaded firefox and tried it there but to no luck.

like image 230
Jamie Hyland Avatar asked Jan 19 '26 07:01

Jamie Hyland


1 Answers

How about you put the login.jpg in the same folder as the css file and change the css to

body
{
    background-image: url("login.jpg");

}

An absolute path is not correct, please use a relative one :)

Folder structure

MyCoolWebApp
|-> stylesheet.css
|-> login.jpg

if you want to access a file that is located in a parent folder of your stylesheet.css file, then use url("../login.jpg");

like image 62
auo Avatar answered Jan 20 '26 22:01

auo