[ACCEPTED]-CSS background image URL failing to load-background-image

Accepted answer
Score: 24

You are using a local path. Is that really 7 what you want? If it is, you need to use 6 the file:/// prefix:


obviously, this will work only 5 on your local computer.

Also, in many modern 4 browsers, this works only if the page itself 3 is also on a local file path. Addressing 2 local files from remote (http://, https://) pages has been 1 widely disabled due to security reasons.

Score: 15

I know this is really old, but I'm posting 8 my solution anyways since google finds this 7 thread.

background-image: url('./imagefolder/image.jpg');

That is what I do. Two dots means 6 drill back one directory closer to root 5 ".." while one "." should mean start where you are at as if it were root. I was having 4 similar issues but adding that fixed it 3 for me. You can even leave the "." in it 2 when uploading to your host because it should 1 work fine so long as your directory setup is exactly the same.

Score: 9

Source location should be the URL (relative 3 to the css file or full web location), not 2 a file system full path, for example:

background: url("http://localhost/media/css/static/img/sprites/buttons-v3-10.png");
background: url("static/img/sprites/buttons-v3-10.png");

Alternatively, you 1 can try to use file:/// protocol prefix.

Score: 1

source URL for image can be a URL on a website 3 like http://www.google.co.il/images/srpr/nav_logo73.png or https://https.openbsd.org/images/tshirt-26_front.gif or if you want to use a local 2 file try this: url("file:///MacintoshHDOriginal/Users/lowri/Desktop/acgnx/image 1 s/images/acgn-site-background-X_07.jpg")

More Related questions