Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Images In another Folder [duplicate]

Tags:

html

css

I added the images into the folder called "images" and CSS to folder called "css", now I want to use the images in "images" folder. How do I do this? When I used this, they didn't show up:

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

I also tried these:

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

What is the path I should be using to access my images?

like image 554
Chathula Avatar asked Apr 03 '13 10:04

Chathula


1 Answers

If you have a folder structure like follows:

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

Then your CSS should work.

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

Read more here: http://css-tricks.com/quick-reminder-about-file-paths/

like image 137
mikkelz Avatar answered Sep 18 '22 06:09

mikkelz