CSS images in another folder

I added images to a folder called "images" and CSS to a folder called "css", now I want to use images in a folder called "images". How can I do it? When I used this, they did not display:

background: url('/images/bg.jpg'); 

I also tried:

 background: url('../images/bg.jpg'); background: url('../../images/bg.jpg'); 

What is the path I should use to access my images?

+6
source share
3 answers

If you have a folder structure, for example:

 /public_html/ /css/ /images/ /index.html 

Then your CSS should work.

  • Starting with "/" it returns to the root directory and starts there
  • Starting with "../" moves one directory back and starts there
  • Starting with "../../" moves two directories back and starts there (and so on ...) To move forward, just start from the first subdirectory and continue to move forward.

More details here: http://css-tricks.com/quick-reminder-about-file-paths/

+12
source

Here is the same question answerd fooobar.com/questions/16153 / ....

here is the W3C specification from the answer http://www.w3.org/TR/REC-CSS1/#url

In other words, it refers to Folder Structur, as indicated in your Post, to Sport Billy .

I hope this helps

+2
source

When using background images, make sure that you also specify the width and height of the container containing the images.

+1
source

All Articles