I am having trouble displaying a background image on a web page and have no clue what’s wrong. I am sure it’s something simple that I just don’t see. Here is the code:
/does not work/
/moved jpg to root directory. does not work/
<p>This text displays in the header</p>;
The solidgreen.jpg file is a test file I created thinking there might be something wrong with the jpg file I am trying to display. Nothing works.
Thanks for any suggestions or help with this simple, perplexing problem.
That’s no use unless the css file is in the root folder too. Looks like a file path problem. Where is the css file in relation to the image? (That is, what’s your file structure?) We could check for you if you post a link.
If the image is in the root directory then you can reference it with /solidgreen.jpg, no matter where your CSS and HTML files are in the structure.
I am developing the site on my computer and don’t have a link you can see. The css folder and pictures folder are both in the root directory. What I have is:
I believe it is a path problem, also, but I can’t see what it is.
I have a copy of the jpg in the root directory.
Is this correct notation:
It does not display.
A friend suggested I zip the directory on my computer and post it. You could see the whole website. It is not a large site at this point. Would that be helpful?
What Stevie meant was this:
Actually, though, using
locally won’t work, unless you are using a server environment like WAMP or MAMP.
The code that you posted initially should work if your folder structure is as you said.So yes, if you wish, zip the files and post them.
This is EXACTLY why my directory structure ALWAYS points down-tree… if you have to root or uptree (…/) it over something simple like a image link, you probably have your file structure needlessly convoluted. Images for CSS should be in a subdirectory of wherever the CSS is – since they are inherently (or should be) presentational that also makes reskinning easier as you can swap out CSS images and the CSS (theme) without effecting the content.
SERIOUSLY, if you have to start a URL in your CSS with “/” or “…/” there is probably something horribly wrong with your directory structure.
I uploaded the zip file, but I don’t see it. I will check back and upload it again if it does not appearl
I have finally solved the problem. As all of you have suggested, it was a syntax issue. Thanks to all who gave me suggestions. I tried them all until I hit paydirt.