Derleek Posted August 19, 2008 Share Posted August 19, 2008 So i have a question about CSS images and the url('img/location') command. Ok lets say we have a directory 'root'. Now in the root directory we have a folder called 'css' with a style.css file, a folder 'images' (duh, with all the images in it ), and an index.html file. So we have: root/index.html root/images/img.jpg root/css/style.css In order to use an image as a background for <div id='image'></div> in the background: url('img/directory') command, does the syntax go url('root/images/img.jpg') or url('images/img.jpg') Quote Link to comment Share on other sites More sharing options...
vipersleaf Posted August 20, 2008 Share Posted August 20, 2008 yeah it would url {images/pic.jpg} or whatever your pic name is Quote Link to comment Share on other sites More sharing options...
haku Posted August 20, 2008 Share Posted August 20, 2008 I usually do my URLs relative to the root. This means you start with a forward slash, then put the path down to the file. So I would use url(/root/images/img.jpg) In this way it doesn't matter where the filesreside, as the target file is always found from the root. So you can move your CSS wherever you want and it should still work. (note: test this, don't take me at my word.) Quote Link to comment Share on other sites More sharing options...
Derleek Posted August 20, 2008 Author Share Posted August 20, 2008 thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.