Jump to content

path to find img


jnf555
 Share

Recommended Posts

Right looking at this again, you have css file whatever.css in css folder, which contains body styling, YES!and a images folder INSIDE the css folder yes!, and within that 'images folder a stars.jpg' image, yes! then it should bebody{background-image:url('images/stars.jpg');}if the images folder with image inside, is outside the css folder, then it would bebody{background-image:url('../images/stars.jpg');}if the image is outside image folder, and can be seen along with, css folder and image folder, then it should be body{background-image:url('../stars.jpg');}

Edited by dsonesuk
Link to comment
Share on other sites

spot on works finebody{background-image:url('../images/stars.jpg');}can you please tell me if i have set my site up the hard wayi have a folder for my site, and then put other folders within it to house my css images etc, or is it best to let all the files live together in the main site folder thanks jnf555

Link to comment
Share on other sites

no, setting them up this way will work, you just have to keep it mind when writing out your file paths. The only thing that might make it easier is to keep your stylesheet and html pages together, and then put all your images and scripts in subfolders. Then the paths in both the HTML and CSS will be the same.

Edited by thescientist
Link to comment
Share on other sites

Here is a good discussion of relative file pathsit explains visually the difference between"image/picture.gif""/image/picture.gif""../image/picture.gif"As for relative to the document and relative to the CSS, I find the best approach is to place the CSS at the top level. That way any relative file paths in the CSS are "down from root"

Link to comment
Share on other sites

What i generally do, is have images, that relate to design layout, logos, borders, headings, backgrounds etc within a image folder inside the css folder, images relating to page content are kept in a separate images folder.all you have to do, is get the correct link to the css file, if the image path is correct in relation to the css file it will work with no problem and show these images on the page.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...