Css problems

I uploaded my files to htdocs folder and my CSS file loaded in like 50%, then I moved CSS file to my img folder, it loaded more but still not all (it didn’t load all images only few of them etc.)
if I move to domain/index.html it load even less

Please explain your issue in more detail and provide your website URL.

Paths in CSS are relative to the location of the stylesheet. If it is a linked stylesheet, then it is the path of the CSS file. If it is embedded in an HTML document (with the style element or attribute) then it is relative to the HTML document.

The path is always relative to the path the file referring to it is in.
So, let’s say your CSS is in /css/style.css (in folder css)

and images are in the path /img/ (htdocs/img/)

then you refer to that image in CSS with:

background-image:url(../img/myimg.jpg) (this is just an example)

what this code above says ? ../img/

  1. get one step out of the css folder ../
  2. look around and find the img folder img/

Simply imagine you are that external CSS file
and watch with your eyes where anything is from you (above or below or in the same dir)

../ = one level up (folder) from CSS file / You

../../ = 2 level up (folders)

and so on…

img is in the same dir where the CSS file is = background-image:url(myimg.jpg)

img is in the subdir love where the CSS file is = background-image:url(love/heart.png)


This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.