Help - Search - Members - Calendar
Full Version: Attempting to use external CSS file to display background image
HTMLHelp Forums > Web Authoring > Cascading Style Sheets
straygrey
I have a web page at www.umdwebo.za.net with:-
<body background="images/rockart.jpg">
coded within the HTML. This works but I want that effect to come from a style.css file and I have therefore written :-
body {background-image: url(images/rockart.jpg) }
into the style.css file,which I do link rel to, but cannot get this background image to display.

Please tell me how I got this wrong?
JamieHarrop
Because your stylesheet is in the "style" directory, you will need to use "../" at the start of the background src. So, rather than using:

CODE
body {background-image: url(images/rockart.jpg) }


Try using:

CODE
body {background-image: url(../images/rockart.jpg) }


By using the first piece of code, you are trying to locate the image from www.umdwebo.za.net/style/images/rockart.jpg

By adding "../" to the start, it tries to locate it from www.umdwebo.za.net/images/rockart.jpg
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.