| | |

CSS URL Path to Background Image / or ./ or ../ or ../../

I always forget the CSS URL path to background images. Thanks TechGnome from the WordPress.org Support Forums.

If the path to CSS (or any file for that matter) leads off with the / that means go to the root and begin look there. A single DOT in front of the slash means look in current dir, and two dots means go up one level and look there.

So, if I’m currently in say http://www.mysite.com/posts/2004/06/04/Test_Post
and the path to my CSS (which is in the CSS folder off the root) is:
css/style.css – it will try to find the css folder under Test_Post, which doesn’t exist, and not load the css file.

If I have ../css/style.css, it will attempt to go to the css folder under the 04 folder, again it doesn’t exist.
If the path is: /css/style.css then it will go all the way up the tree to my root and find the css folder (which does exist) and then load the css from there – which it will do successfully.

BTW: same thing happens with images. If you are using permalinks and images disapper, this maybe the cause.


Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *