Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Cascading Style Sheets _ Unable to load image using backgound image in CSS

Posted by: Richie McCaw Apr 26 2007, 05:08 PM

I am having trouble loading background images to my page using style sheets. All other styles are loading fine but when I try a

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

style it won't load. It wont work with any element. I can load any images directly in the html page and even in a with the body tags. Can anybody help?

Posted by: JamieHarrop Apr 26 2007, 05:30 PM

I'm going to take a guess and say this is because you're not pointing the URL to the correct location of the image.

For example:

If image.gif is inside the directory "graphics" and your stylesheet is inside a directory called "includes", you'll need to use "../graphics/image.gif" to point to the image.

The "../" at the start of that URL tells the browser to look one directory level down before proceeding to look inside the "graphics" directory.

If you can post a link to the Web site in question, we may be able to determine the location of the image, and tell you what URL you need to use to point to it.

Posted by: Shadeaux Apr 26 2007, 05:43 PM

I was going to say the same thing. Every time I've had a style sheet that wouldn't load a background image it was because I pointed to a location off my root directory, and the style sheet was in a "Styles" directory..

Posted by: Richie McCaw Apr 27 2007, 07:29 AM

Yes that was the case and solved my problem. Thanks fot your help.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)