Msg#: 4427584 posted 7:44 pm on Mar 10, 2012 (gmt 0)
its probably something to do with the URL. is the image in the same directory as the html file? that would work okay for the inline method. but if you try it with a css file, then the way you've got it written at the moment, the image would have to be in the same directory as the css file.
try changing background-image: url("skystrip.gif"); to background-image: url("/directory/skystrip.gif"); or wherever it is that the image is stored
Msg#: 4427584 posted 9:54 pm on Mar 10, 2012 (gmt 0)
but if you try it with a css file, then the way you've got it written at the moment, the image would have to be in the same directory as the css file.
Other way around. Relative links in external css are treated as relative to the file that uses the css, not to the css itself.
I only know this because I've gone through the "get it wrong + test it" loop about eight times in the past year. Ahem.
Site-absolute links are guaranteed to work correctly. The drawback is that you can't test them locally except by installing a pseudo-server like MAMP or WAMP. (And then jumping through further hoops if you're testing more than one domain.)
The leading slash means "start at the domain root." It's a good habit to form early. Note that this will NOT work if you're previewing on your local computer because your local computer is not a web server and doesn't have a "domain root" (unless you add server software to it.) Using the above directory structure, you'll have to do
This will work in both cases, so what's the difference? When you get into large web sites and begin URL rewriting, it will become painfully apparent that the document-relative syntax will get very difficult to maintain. IF you always start at domain root, it's one less thing to worry about.