These days I meet so many problems about the path in css and js. And after a few tests,I can not have a exact answer,so i ask here for help.
1 The
The path is always relative to the path the file referring to it is in. So, let's say your css is in /css/mystyel.css
and images are in the path /img
, then you refer to that image in css with:
background-image:url(../img/myimg.jpg)
If your js in in /js/myscript.js
and you are adressing it from a html-file like /somepath/somehtml.html
, then you use:
If the html was in /somepath/somotherpath/somehtml.html
, you would have used src="../../js/myscript.js"