Url() - relative paths not working

E.g.

background-image:url(/images/pic.jpg);

…does not work. I have to put in the full address. Obviously not a good practice, I may be moving the site to another folder in future.

Any ideas?

If the css is in an external stylesheet remember that path is relative to the css document.

also shouldn’t there be quotes round the url?:

background-image:url(‘/images/pic.jpg’);

i suspect not absolutely necessary but better maybe?

The style is within the html file. I should really move it to an external however.

Didn’t add the quotes, but I will give it a go.

Thanks.

The style is within the html file. I should really move it to an external however.

Didn’t add the quotes, but I will give it a go.

Thanks.

also /images/pic.jpg isn’t strictly a relative url is it? there’s three types of urls not two. there’s absolute as in a full address starting with http, there’s relative (which never starts with a slash) which is relative to whichever document, then there’s /images/pic.jpg type urls which i don’t have a name for [*] but they’re semi relative semi absolute. it’s absolute on the server but relative to the server… anyway, are you sure you want /images/pic.jpg and not say images/pic.jpg which is a relative url.

the starting slash starts the path from the root directory, so for /images/pic.jpg to work the images directory would need to be in the root directory of the server – /images/pic.jpg is not relative to the html nor css file apart from it’s pointing to a file on the same server as the html or css it’s in.

.[*] “absolute, local to the server, address” ? who knows.

What’s the full address? If you/we compare the two, there might be a typo…

thats it! It IS a relative url and I had to get rid of the first slash before ‘images’ and I had to put it in quotes.

So now working, thanks all!