-1

I need help with one situation. I creat file structure :

  • MainFolder
    • index.html
    • IMGfolder
      • bg.jpg
    • CSSfolder
      • style.css

I need link picture bg.jpg relative url in my CSS style file :

background-color: url('?');

I try

/img/bg.jpg
../img/bg.jpg

but, it's not working. Thanks for help :)

  • 1
    `IMGfolder`? Is it called like that or is it actually called `img`? Please include the actual _folder names_ in your file structure. – Sebastian Simon Jul 23 '15 at 14:42
  • 1
    What is your *actual* folder structure? You say `img` and `IMGfolder`. Which is it? And what URL do you visit to view `MainFolder/index.html` in the browser? – ceejayoz Jul 23 '15 at 14:55
  • 1
    Please check in the debugging tools: is your CSS file loaded? Which actual image path is being tried to load? – Sebastian Simon Jul 23 '15 at 15:00
  • sorry, img mean IMGfolder, and i want to write it in style.css file. – Norbert Bago Jul 23 '15 at 15:22
  • @NorbertBago If the folder is called `IMGfolder` then `../img/bg.jpg` as stated in your question won't work. You have to use the actual folder name. – ceejayoz Jul 23 '15 at 15:24

1 Answers1

1

Just add some lines of php in your html using getcwd() to be sure your relative path is correct.

BTW: In UNIX systems:

  • / refers to the root directory
  • ./ refers to the current directory
  • ../ refers to the directory, in which the current directory is
Julian Berger
  • 157
  • 1
  • 10